我在GUI中创建了一个包含2个选项的菜单,我还在2个选项之间使用了add_separator()。还有一个状态栏,当鼠标悬停在任何选项上时,它会提供描述。
我的问题是,分隔线后的任何选项怎么没有在状态栏中提供任何描述?它改变了它的索引位置吗?
def helpMenuStatusBar(self, event = None):
if self.parent.call(event.widget, "index", "active") == 0:
self.statusBar.set("Select available files")
elif self.parent.call(event.widget, "index", "active") == 1:
self.statusBar.set("About This Application")
else:
self.statusBar.set("")
self.helpMenu = Menu(menubar, tearoff = 0, postcommand = self.updateMenu)
self.helpMenu.add_command(label = "Available files", command = self.availableFiles, state = "disabled")
self.helpMenu.add_separator()
self.helpMenu.add_command(label = "About", command = self.onAbout)
menubar.add_cascade(label = "Help", menu = self.helpMenu)
self.helpMenu.bind("<<MenuSelect>>", self.helpMenuStatusBar)
答案 0 :(得分:0)
添加分隔线后,这将被视为菜单项之一。所以在这种情况下:
def helpMenuStatusBar(self, event = None):
if self.parent.call(event.widget, "index", "active") == 0:
self.statusBar.set("Select available files")
elif self.parent.call(event.widget, "index", "active") == 2:
self.statusBar.set("About This Application")
else:
self.statusBar.set("")