我在python中使用tkinter,然后我在tkiner中更改了文件菜单栏的字体,但只是更改了文件内部的内容,而不是“ File”,我想更改“ File”,“ Edit”和“ Help”的字体“在我的代码中,而不是其中的内容。
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()
答案 0 :(得分:0)
菜单栏是受基础操作系统控制的本地组件。我认为tkinter不可能更改菜单栏的字体。