如何更改 ttk::button (主题小部件)中的字体和字体大小?

发布于 2024-08-25 16:19:20 字数 179 浏览 5 评论 0原文

如何更改主题按钮小部件 (ttk::button) 中的字体和字体大小?

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烟酒忠诚 2024-09-01 16:19:20

ttk::button 的外观(特别是对你来说,它的字体,但其他东西也是如此)完全通过样式和主题控制。通过设置一次样式,可以轻松地将其应用到许多按钮(假设这就是您想要的)。

最简单的方法是创建派生样式,这是通过在现有基本样式(按钮的 TButton)上添加一些自定义前缀来完成的。

# 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

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
我家小可爱 2024-09-01 16:19:20

您可能会在此 Tk 教程页面上获得所需的答案: http://www.tkdocs .com/tutorial/styles.html

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文