'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!
Solution 1:[1]
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)
Solution 2:[2]
The Above answer is correct and you can change the style for all of ttk widgets(for example font) you can change the root's style whose name is '.':
s = ttk.Style()
s.configure('.', font=('Helvetica', 12))
After that, all of your ttk widgets's uses 'Helvetica' font in size '12'. The answer, derived from "https://tkdocs.com/shipman/ttk-style-layer.html"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | S.M.R.Sadeghi |