This seems like a silly question, but is it possible to change the height of a ttk button manually?
Something like button = tkinter.Button(frame, text='hi', width=20, height=20...)
works just fine for a tkinter button. Though I'd prefer to use a ttk button since it looks much better aesthetically.
button = ttk.Button(frame, text='hi', width=20, height=20...)
does not work, height doesn't seem to be a valid option. I've tried setting it with config or looking for elements in the style to change and haven't had any luck.
Is there a simple solution to this? I'm using Python 2.7, Windows for the record. Sorry, this seems like kind of a trivial questions but I've looked around without much luck.
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.
Build A Paint Program With TKinter and Python In order to customize the Button size, we can use the width and height property of the button widget.
This worked for me:
my_button = ttk.Button(self, text="Hello World !")
my_button.grid(row=1, column=1, ipady=10, ipadx=10)
where ipady
and ipadx
adds pixels inside the button unlike pady
and padx
which adds pixels outside of the button
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