【问题标题】:wxPython - Add tooltip to menu itemswxPython - 向菜单项添加工具提示
【发布时间】:2015-05-09 02:48:34
【问题描述】:

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

【问题讨论】:

    标签: python wxpython tooltip


    【解决方案1】:

    据我所知,似乎共识是您希望绑定一个事件以收听 wx.EVT_MENU_HIGHLIGHT 或 wx.EVT_LIST_ITEM_SELECTED 然后获取所选菜单的 id 可能与 GetMenuId 并使用一些某种 map/dict 显示帮助消息,或者看起来可以Set the help string 虽然看起来这可能是另一种可能的解决方案:

    另见balloontip:

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

    相关:

    【讨论】:

    • 感谢您的链接。其实,我并没有这样想。我希望有一种简单的方法来做到这一点,以便为菜单元素提供简单的工具提示。
    • 有:wxpython.org/Phoenix/docs/html/ToolTip.html?highlight=tooltip ... 但这似乎是针对整个窗口的。如果他们有时间,您可能会收到 Mike 或 Robin 的回复。它们通常在 wxpython 标签上非常活跃。我还添加了另一个指向 balloontip 的链接。
    猜你喜欢
    • 2015-10-12
    • 2019-08-14
    • 1970-01-01
    • 2017-06-03
    • 1970-01-01
    • 2011-01-25
    • 2016-10-08
    • 2011-10-30
    相关资源
    最近更新 更多