33

I am doing a simple project in school and I need to make six different buttons to click on. The buttons must have different sizes, but I can't find how do do it. I have made the button by using:

def __init__(self, master):
    super().__init__(master)
    self.grid()
    self.button1 = Button(self, text = "Send", command = self.response1)   
    self.button1.grid(row = 2, column = 0, sticky = W)

I imagine that something like:

self.button1.size(height=100, width=100)

would work, but it doesn't and I cannot find how to do it anywhere.

I am using Python 3.3.

Community
  • 1
  • 1
John Forsgren
  • 353
  • 1
  • 3
  • 4
  • 5
    You need to show more of the code than this (and fix the indentation). What toolkit are you using? wx? Tkinter? GTK? – mgilson Jan 09 '13 at 22:35
  • 7
    By "the latest version of Python to this date" you mean 3.3? That's usually more helpful to say, especially since there are some old fogies out there who still consider 2.7 "the latest Python" because it's the latest 2.x… But, more importantly, if someone reads this question in 2015, he's not going to want to go look up the history of Python releases to figure out whether the answer is up to date… – abarnert Jan 09 '13 at 22:43

2 Answers2

61

Configuring a button (or any widget) in Tkinter is done by calling a configure method "config"

To change the size of a button called button1 you simple call

button1.config( height = WHATEVER, width = WHATEVER2 )

If you know what size you want at initialization these options can be added to the constructor.

button1 = Button(self, text = "Send", command = self.response1, height = 100, width = 100) 
cdbitesky
  • 1,390
  • 1
  • 13
  • 30
2

I've always used .place() for my tkinter widgets. place syntax

You can specify the size of it just by changing the keyword arguments!

Of course, you will have to call .place() again if you want to change it.

Works in python 3.8.2, if you're wondering.

PythonPikachu8
  • 359
  • 2
  • 11