wxPython - 向菜单项添加工具提示

wxPython - Add tooltip to menu items

如何向 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 )

据我所知,大家似乎达成了共识,即您希望绑定一个事件来监听 wx.EVT_MENU_HIGHLIGHTwx.EVT_LIST_ITEM_SELECTED,然后获取所选菜单的 id也许 GetMenuId and using some sort of map/dict display the help message, or it looks like it might be possible to Set the help string 虽然看起来这可能是另一种可能的解决方案:

  • How to tweak my tooltips in wxpython?

另见 balloontip:

我不确定现在是否仍然如此,因为其中一些答案有点过时了。

相关: