我在 python 中使用 tkinter,然后我在 tkiner 中更改了文件菜单栏的字体,但只是更改了文件内部的内容而不是“文件”我想更改“文件”、“编辑”和“帮助”的字体编码而不是它们内部的内容。
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()