Question

How do you change the font and font size in the themed button widget (ttk::button)?

ttk::button .x.buttonTEST -text "TEST" -font ??
# the -font option is not valid with ttk::button
Was it helpful?

Solution

The look of a ttk::button (in particular for you, its font, but other things too) is controlled exclusively through the style and theme. By setting up the style once, it becomes easy to apply it to many buttons (assuming that's what you want).

The simplest way to do this is to make a derived style, which is done by prepending some custom prefix onto an existing base style (TButton for buttons).

# Once per style in your program...
ttk::style configure MyExample.TButton -font {Symbol 48}

# For each button you want that looks this way...
ttk::button .b -font "Example" -style MyExample.TButton
pack .b

OTHER TIPS

You'll probably get the answers you want on this Tk tutorial page: http://www.tkdocs.com/tutorial/styles.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top