Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing ttk Button Height in Python

Tags:

tkinter

ttk

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.

like image 375
user1301039 Avatar asked Mar 29 '12 14:03

user1301039


People also ask

How do you adjust the height on a TTK button?

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.

How do you resize a button in Python?

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.


1 Answers

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

like image 117
Benyassine Adnan Avatar answered Sep 24 '22 14:09

Benyassine Adnan