How to change font size in ttk.Button?

David González Blazman picture David González Blazman · May 6, 2016 · Viewed 12.4k times · Source

This is my problem, I was building an interface for a program, but for needs of the bosses, the font must be larger. I have changed the font size of every widget without any problem, but with the ttk.Buttons, I was unable to change it... I was reading that ttk.Button doesn't support the font attribute, but tk.Button supports it. I tried with tk.Button and it works, but I don't like the graphic style of this tk.Button...

Is there any way to change the font style and size of a ttk.Button, or changed the graphic style of the tk.Button to make similar to the ttk?

Thanks to everyone!

Answer

Roland Smith picture Roland Smith · May 6, 2016

You have to use styles to customize ttk widgets.

s = ttk.Style()
s.configure('my.TButton', font=('Helvetica', 12))
b = ttk.Button(mainframe, text='Press me', style='my.TButton',
command=foo)