当试图将鼠标移到菜单元素上时,我试图显示一个不同的光标,我认为要做到这一点,您必须在创建菜单时在选项上添加 if (sound)
sound = true;
audio.play();
选项。
var audio = document.getElementById("sound1");
$('#topleft').addClass('litTopLeft');
但是由于光标没有变化,我该怎么做?
答案 0 :(得分:1)
tkinter Menu
的{{3}}指出光标选项表示“ The cursor that appears when the mouse is over the choices, but only when the menu has been torn off
”。因此,我认为您实际上无法做到自己想要的。仅当子菜单已分离(撕下)时,您才能看到光标发生变化。这是一个演示。
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="plus")
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()