Is there any way to change the selected font color of a menu item in Tkinter? I assumed it was selectcolor but I haven't been able to get that to do anything. Help would be much appreciated.
I would like to have the "Save" text stay black when I hover the cursor over it. I'm just using effbot.org's sample code for now:
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()
There are activebackground
and activeforeground
options using which you can change the background and foreground color on Hover.
Replace this
filemenu.add_command(label="Save", command=hello)
with this
filemenu.add_command(label="Save", command=hello, activeforeground = 'black')
Hope this works as expected :)