[Window Manager] 请问使用python的tkinter开发的应用使用的字体从哪里设置呢?
Tofloor
poster avatar
咿呀
deepin beta test group
2025-02-18 10:56
Author

请问使用python的tkinter开发的应用使用的字体从哪里设置呢?
系统设置中更改了字体但是使用python的tkinter开发的应用字体并没有更换

1739847156382.png

Reply Favorite View the author
All Replies
把一切操作变成GUI
deepin
Backbone of ecological co-construction group
2025-02-18 11:45
#1

在你的代码里面设置试试

import tkinter as tk

root = tk.Tk()
root.option_add("*Font", ("Helvetica", 12))

假如是 ttk的话:

from tkinter import ttk

style = ttk.Style()
style.configure(".", font=("Helvetica", 12))

隶书是我在星火商店安装的字体
image.png

image.png

Reply View the author
咿呀
deepin beta test group
2025-03-12 11:02
#2
把一切操作变成GUI

在你的代码里面设置试试

import tkinter as tk

root = tk.Tk()
root.option_add("*Font", ("Helvetica", 12))

假如是 ttk的话:

from tkinter import ttk

style = ttk.Style()
style.configure(".", font=("Helvetica", 12))

隶书是我在星火商店安装的字体
image.png

image.png

感谢感谢agree

Reply View the author