开发者

How to change the font and font size in ttk::button (themed widgets)?

开发者 https://www.devze.com 2022-12-23 19:19 出处:网络
How do you cha开发者_JAVA技巧nge the font and font size in the themed button widget (ttk::button)?

How do you cha开发者_JAVA技巧nge 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


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号