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.
Tkinter Button ShapeShapes can be rectangular, oval, circle, etc. You cannot create a rounded button directly from the widget. to do so you need a rounded image. And then reduce the border width to 0.
We can change the height of the ttk button by using the grid(options) method. This method contains various attributes and properties with some different options. If we want to resize the ttk button, we can specify the value of internal padding such as ipadx and ipady.
The Button widget is used to add buttons in a Python application. These buttons can display text or images that convey the purpose of the buttons. You can attach a function or a method to a button which is called automatically when you click the button.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With