Howdy,
Python 3.6.6, wxPython 4.0.3
I have an application with a toolbar, menubar, and right click context menu (Linked to a list control). The menubar and toolbar help text is displayed ok. The right click menu help text isnt displayed in the statusbar and instead anything that was in the status bar is erased. So, I want to create a helper to display the help text by binding EVT_MENU_HIGHLIGHT. The problem is that I cant get access to the menu’s help text information. My popup menu is in one class. The main class has the EVT_MENU_HIGHLIGHT binding.
below I have included the popup menu class. In the main class I have
self.Bind(wx.EVT_MENU_HIGHLIGHT, self.on_help_string)
Then in the main class I want to do something like;
def on_help_string(self, event):
print(event)
event_id = event.GetId()
help_text = ''
print(event_id)
print(MyPopupMenu.GetHelpString())
But you cant do that. The GetHelpString is asking for a Manu item. Any ideas how to solve this?
class MyPopupMenu(wx.Menu):
def __init__(self, parent, position):
wx.Menu.__init__(self)
# Only do this once so that we get the bindings done
if not hasattr(self, 'on_double_click_id'):
print('event bound')
self.on_double_click_id = wx.NewId()
self.on_suppress_short_version_id = wx.NewId()
self.on_play_with_model_2_id = wx.NewId()
self.on_play_with_model_3_id = wx.NewId()
self.on_verify_roms_id = wx.NewId()
self.on_rom_info_id = wx.NewId()
self.on_add_favorite_id = wx.NewId()
self.on_set_rating_id = wx.NewId()
self.on_preferences_game_id = wx.NewId()
self.on_reset_to_mame_id = wx.NewId()
self.Bind(wx.EVT_MENU, parent.on_double_click, id=self.on_double_click_id)
self.Bind(wx.EVT_MENU, parent.on_suppress_short_version, id=self.on_suppress_short_version_id)#
self.Bind(wx.EVT_MENU, parent.on_play_with_model_2, id=self.on_play_with_model_2_id)
self.Bind(wx.EVT_MENU, parent.on_play_with_model_3, id=self.on_play_with_model_3_id)
self.Bind(wx.EVT_MENU, parent.on_reset_to_mame, id=self.on_reset_to_mame_id)
self.Bind(wx.EVT_MENU, parent.on_verify_roms, id=self.on_verify_roms_id)
self.Bind(wx.EVT_MENU, parent.on_rom_info, id=self.on_rom_info_id)
self.Bind(wx.EVT_MENU, parent.on_add_favorite, id=self.on_add_favorite_id)
self.Bind(wx.EVT_MENU, parent.on_set_rating, id=self.on_set_rating_id)
self.Bind(wx.EVT_MENU, parent.on_preferences_game, id=self.on_preferences_game_id)
# Detect which row we are hovering over in the list control and make that row selected
item, flags = parent.list.HitTest(position)
if item != -1: # Don't allow selecting an item on a row with no items
self.Append(self.on_double_click_id, 'Play Game', 'Play the selected game')
self.Append(self.on_suppress_short_version_id, 'Play Game without softlist HASH support',
'Play the selected system program directly without using the softwarelist '
'HASH file. No support for cheats.')
self.Append(self.on_verify_roms_id, 'Verify ROM',
'Verify the integrity of the selected game rom files')
self.Append(self.on_rom_info_id, 'ROM information',
'Get information on the selected game rom files')
self.Append(self.on_add_favorite_id, 'Add to favorites',
'Add the selected game to my favorites list')
self.Append(self.on_set_rating_id, 'Game Rating',
'Set the star rating for the selected game')
self.Append(self.on_preferences_game_id, 'Game Preferences',
'Set the MAME preferences for this game')
self.Bind(wx.EVT_MENU_HIGHLIGHT, self.on_help_string)
self.Bind(wx.EVT_LIST_ITEM_SELECTED , self.on_help_string)
parent.list.Select(item)