John Forsgren
John Forsgren

Reputation: 353

How do I change button size in Python?

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.

Upvotes: 33

Views: 177904

Answers (2)

PythonPikachu8
PythonPikachu8

Reputation: 344

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.

Upvotes: 2

cdbitesky
cdbitesky

Reputation: 1396

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) 

Upvotes: 63

Related Questions