gpt4 book ai didi

python - 是否可以更改 tkinter 中菜单的字体?

转载 作者:太空宇宙 更新时间:2023-11-03 20:31:12 24 4
gpt4 key购买 nike

我在python中使用tkinter,然后我更改了tkiner中文件菜单栏的字体,但只是更改了文件内部的某些内容而不是"file"我想更改"file"、“编辑”和“帮助”的字体“在我的代码中不是它们内部的内容。

from tkinter import *

def donothing():
filewin = Toplevel(root)
button = Button(filewin, text="Do nothing button")
button.pack()

root = Tk()
menubar = Menu(root,font=('Franklin Gothic Demi Cond', 11))
filemenu = Menu(menubar, tearoff=0,activeborderwidth=4,activeforeground='red2',fg='blue',bg='thistle4',font=('Franklin Gothic Demi Cond', 11))
filemenu.add_command(label="New", command=donothing,font=('Franklin Gothic Demi Cond', 11))
filemenu.add_command(label="Open", command=donothing,font=('Franklin Gothic Demi Cond', 11))
filemenu.add_command(label="Save", command=donothing,font=('Franklin Gothic Demi Cond', 11))
filemenu.add_command(label="Save as...", command=donothing,font=('Franklin Gothic Demi Cond', 11))
filemenu.add_command(label="Close", command=donothing,font=('Franklin Gothic Demi Cond', 11))

filemenu.add_separator()

filemenu.add_command(label="Exit", command=root.quit,font=('Franklin Gothic Demi Cond', 11))
menubar.add_cascade(label="File", menu=filemenu,font=('Franklin Gothic Demi Cond', 11))
editmenu = Menu(menubar, tearoff=0,activeborderwidth=4,activeforeground='red2',fg='blue',bg='thistle4',font=('Franklin Gothic Demi Cond', 11))
editmenu.add_command(label="Undo", command=donothing,font=('Franklin Gothic Demi Cond', 11))

editmenu.add_separator()

editmenu.add_command(label="Cut", command=donothing,font=('Franklin Gothic Demi Cond', 11))
editmenu.add_command(label="Copy", command=donothing,font=('Franklin Gothic Demi Cond', 11))
editmenu.add_command(label="Paste", command=donothing,font=('Franklin Gothic Demi Cond', 11))
editmenu.add_command(label="Delete", command=donothing,font=('Franklin Gothic Demi Cond', 11))
editmenu.add_command(label="Select All", command=donothing,font=('Franklin Gothic Demi Cond', 11))

menubar.add_cascade(label="Edit", menu=editmenu,font=('Franklin Gothic Demi Cond', 11))
helpmenu = Menu(menubar, tearoff=0,activeborderwidth=4,activeforeground='red2',fg='blue',bg='thistle4',font=('Franklin Gothic Demi Cond', 11))
helpmenu.add_command(label="Help Index", command=donothing,font=('Franklin Gothic Demi Cond', 11))
helpmenu.add_command(label="About...", command=donothing,font=('Franklin Gothic Demi Cond', 11))
menubar.add_cascade(label="Help", menu=helpmenu)

root.config(menu=menubar)
root.mainloop()

最佳答案

菜单栏是一个 native 组件,受底层操作系统的控制。我认为 tkinter 不可能更改菜单​​栏的字体。

关于python - 是否可以更改 tkinter 中菜单的字体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57495600/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com