wxPython - 将工具提示添加到菜单项

时间:2015-05-09 02:48:35

标签: python wxpython tooltip

如何向wx.Menu()的元素添加工具提示?这是我为这些项目编写的代码:

#Patient menu (1st menu):
self.patientMenu = wx.Menu()
self.registerNewPatient = self.patientMenu.Append( -1, 'Cadastrar paciente...' )
self.listPatientsByName = self.patientMenu.Append( -1, u'Listar pacientes em ordem alfabética' )
self.listPatientsByNumber = self.patientMenu.Append( -1, u'Listar pacientes por número em ordem crescente' )
self.searchForPatients = self.patientMenu.Append( -1, 'Pesquisar paciente(s)...' )
#Appointment menu (2nd menu):
self.appointmentMenu = wx.Menu()
self.seeAppointmentsForToday = self.appointmentMenu.Append( -1, 'Visualizar consultas de hoje' )
self.registerNewAppointment = self.appointmentMenu.Append( -1, 'Marcar consulta...' )
self.cancelAppointment = self.appointmentMenu.Append( -1, 'Desmarcar consulta...' )
self.seeAppointmentsForOtherSpecificDate = self.appointmentMenu.Append( -1, 'Pesquisar consultas...' )
#Exit menu (3rd menu):
self.exitMenu = wx.Menu()
self.exitProgram = self.exitMenu.Append( -1, 'Encerrar' )
#Menu bar:
self.menuBar = wx.MenuBar()
self.menuBar.Append( self.patientMenu, 'Paciente' )
self.menuBar.Append( self.appointmentMenu, 'Consulta' )
self.menuBar.Append( self.exitMenu, 'Sair' )
self.SetMenuBar( self.menuBar )

1 个答案:

答案 0 :(得分:1)

从我可以收集到的内容看来,您可能希望绑定一个事件来收听wx.EVT_MENU_HIGHLIGHTwx.EVT_LIST_ITEM_SELECTED,然后抓住所选菜单的id GetMenuId并使用某种map / dict显示帮助消息,或者看起来可能Set the help string尽管看起来这可能是另一种可能的解决方案:

另见balloontip

我不确定是否仍然如此,因为其中一些答案有点陈旧。

相关: