Python 有没有办法更改Tkinter菜单中选定的字体颜色?
有没有办法更改Tkinter中菜单项的选定字体颜色?我以为它是selectcolor,但我没能让它做任何事情。非常感谢您的帮助 当我将光标悬停在“保存”文本上时,我希望它保持黑色。我现在只使用effbot.org的示例代码:Python 有没有办法更改Tkinter菜单中选定的字体颜色?,python,user-interface,tkinter,tkinter-menu,Python,User Interface,Tkinter,Tkinter Menu,有没有办法更改Tkinter中菜单项的选定字体颜色?我以为它是selectcolor,但我没能让它做任何事情。非常感谢您的帮助 当我将光标悬停在“保存”文本上时,我希望它保持黑色。我现在只使用effbot.org的示例代码: from tkinter import * root = Tk() def hello(): print("hello!") menubar = Menu(root) # create a pulldown menu, and add it to the me
from tkinter import *
root = Tk()
def hello():
print("hello!")
menubar = Menu(root)
# create a pulldown menu, and add it to the menu bar
filemenu = Menu(menubar, tearoff=0)
filemenu.add_command(label="Open", command=hello)
filemenu.add_command(label="Save", command=hello)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=root.quit)
menubar.add_cascade(label="File", menu=filemenu)
# create more pulldown menus
editmenu = Menu(menubar, tearoff=0)
editmenu.add_command(label="Cut", command=hello)
editmenu.add_command(label="Copy", command=hello)
editmenu.add_command(label="Paste", command=hello)
menubar.add_cascade(label="Edit", menu=editmenu)
helpmenu = Menu(menubar, tearoff=0)
helpmenu.add_command(label="About", command=hello)
menubar.add_cascade(label="Help", menu=helpmenu)
# display the menu
root.config(menu=menubar)
root.mainloop()
有
activebackground
和activeforeground
选项,您可以使用这些选项更改悬停时的背景和前景颜色
替换这个
filemenu.add_command(label="Save", command=hello)
用这个
filemenu.add_command(label="Save", command=hello, activeforeground = 'black')
希望它能像预期的那样工作:)有
activebackground
和activeforeground
选项,您可以使用这些选项更改悬停时的背景和前景颜色
替换这个
filemenu.add_command(label="Save", command=hello)
用这个
filemenu.add_command(label="Save", command=hello, activeforeground = 'black')
希望这能如预期的那样起作用:)相关的a