当鼠标到达菜单元素时,我试图显示不同的光标,我认为要做到这一点,您必须cursor='something'
在创建菜单时在选项中添加选项
try:
import tkinter as tk
except ImportError:
import Tkinter as tk
class Settings:
def __init__(self, master):
# Elements of the menu
self.master=master
self.menu = tk.Menu(root, fg="red")
self.subMenu = tk.Menu(self.menu, cursor="hand1")
def openMenu(self):
# Configuration of the menu
self.menu.add_cascade(label="Options", menu=self.subMenu)
self.addOptionsSubMenu()
self.master.config(menu=self.menu)
def addOptionsSubMenu(self):
# Add elements at the sub menu
self.subMenu.add_command(label="Quit", command=self.quit)
self.subMenu.add_command(label="Do nothing", command=self.passa)
# Quit the function
def quit(self):
exit()
# Do nothing
def passa(self):
pass
root = tk.Tk()
app = Settings(root)
app.openMenu()
root.mainloop()
但是由于光标没有改变,我该怎么做?