Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change font size in ttk.Button?

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!

like image 241
David González Blazman Avatar asked May 06 '16 09:05

David González Blazman


People also ask

How do I change font-size in TTK Button?

In the given output, there are two ttk buttons which are having different properties such as font size and color. We can modify the font size by updating the values in the configuration.

How do I increase the font-size of a Button?

To change the font size of a button, use the font-size property.

Can you change font in tkinter?

We can customize the font-property of text widget in a tkinter application using the font('font-family',font-size, 'style') attribute.


1 Answers

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)
like image 184
Roland Smith Avatar answered Sep 21 '22 03:09

Roland Smith