1

I'm still new to tkinter, and noticed that when I tried to increase the size of a button using

 button.config(height=20, width=50)

It didn't work at all. It was just a huge area of white space in the violet background, and then the button in the middle of the white space. If I clicked anywhere within the white space though, it worked and did its command.

Here's the code:

from tkinter import *

root = Tk()
def cheese():
    print ('hi')
logo = PhotoImage('../Desktop/logothing.gif')
explanation = """Flaming Arrows whizz over your hair, War rages around you. Suddenly,
it charges into you. A 8 foot tall mechanical beast the enemy have been training for war.
You have no chance but to fight it. You swing your sword as hard as you can...Only to
leave a minor dent on it's armor. With one blow from its club, you fall unconscious."""

w2 = Label(root, justify=LEFT, text=explanation, image = logo, 
           compound = CENTER, fg="blue", bg= "Violet", 
        font="ComicSansMS 32 bold",padx=1000, pady=1000).pack(side='left')
w1 = Button(root, text = 'Hello',command = cheese, padx=10)
w1.config(height=20, width = 50)
w1.place(x=500, y=500)
nbro
  • 15,395
  • 32
  • 113
  • 196
1pokepie
  • 72
  • 8
  • What platform are you running on? If a Mac, you won't be able to resize buttons due to platform restrictions. That's the price we pay for native widgets. – Bryan Oakley Jan 18 '15 at 04:23
  • Yea, I'm on a mac :/ So there's no way at all to change the button size for us Mac users? – 1pokepie Jan 18 '15 at 04:26
  • @1pokepie, I think you can check if the problem is caused by the button or by something else by removing the code for `w2`... – nbro Jan 18 '15 at 05:04
  • 1
    Nope, no way at all to change the button size on a mac. You can use a label, canvas or frame and add bindings so it works like a button. Here's an example using a canvas: http://stackoverflow.com/a/19369991/7432 – Bryan Oakley Jan 18 '15 at 13:22

2 Answers2

1

I have tested on my Mac and it seems that you cannot resize the height of the button (it works as if it was the pady), but just the width. In fact, if you decrease the height of your button to 1, you will have something like this:

enter image description here

The only workaround I can see is to increase the size of the font. If you use pady, you will just increase vertically the white box containing the button.

This might be a platform specific problem, as Bryan Oakley mentioned in a comment.

nbro
  • 15,395
  • 32
  • 113
  • 196
0

Increasing the font size doesn't work. This is what I got when I tried it because I'm experiencing the same problem.

font going off the button

Zach
  • 3
  • 1
  • 3