Changing ttk Button Height in Python

user1301039 picture user1301039 · Mar 29, 2012 · Viewed 16.9k times · Source

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.

Answer

Benyassine Adnan picture Benyassine Adnan · Feb 16, 2018

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