Skip to content

Commit

Permalink
fix: remove crash when calling the profile menu twice
Browse files Browse the repository at this point in the history
closes #269
  • Loading branch information
clementb49 committed Oct 7, 2024
1 parent 58bcbad commit df9cbd5
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions basilisk/gui/main_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,6 @@ def update_item_label_suffix(item: wx.MenuItem, suffix: str = "..."):
item.SetItemLabel(item.GetItemLabel() + suffix)

menu_bar = wx.MenuBar()
self.manage_profile_item = wx.MenuItem(
id=wx.ID_ANY,
# Translators: A label for a menu item to manage conversation profiles
text=_("Manage conversation &profiles") + "...\tCtrl+Shift+P",
)
self.Bind(
wx.EVT_MENU,
self.on_manage_conversation_profiles,
self.manage_profile_item,
)

conversation_menu = wx.Menu()

Expand Down Expand Up @@ -160,7 +150,7 @@ def update_item_label_suffix(item: wx.MenuItem, suffix: str = "..."):
_("Manage &accounts") + "...\tCtrl+Shift+A",
)
self.Bind(wx.EVT_MENU, self.on_manage_accounts, manage_accounts_item)
tool_menu.Append(self.manage_profile_item)
tool_menu.Append(self.build_manage_profile_item())
preferences_item = tool_menu.Append(wx.ID_PREFERENCES)
self.Bind(wx.EVT_MENU, self.on_preferences, preferences_item)
update_item_label_suffix(preferences_item, "...\tCtrl+,")
Expand Down Expand Up @@ -631,6 +621,19 @@ def show_dialog():

wx.CallAfter(show_dialog)

def build_manage_profile_item(self) -> wx.MenuItem:
manage_profile_item = wx.MenuItem(
id=wx.ID_ANY,
# Translators: A label for a menu item to manage conversation profiles
text=_("Manage conversation &profiles") + "...\tCtrl+Shift+P",
)
self.Bind(
wx.EVT_MENU,
self.on_manage_conversation_profiles,
manage_profile_item,
)
return manage_profile_item

def build_profile_menu(self, event_handler) -> wx.Menu:
"""
Build the conversation profile menu.
Expand All @@ -642,7 +645,7 @@ def build_profile_menu(self, event_handler) -> wx.Menu:
profile_item = profile_menu.Append(wx.ID_ANY, profile.name)
self.Bind(wx.EVT_MENU, event_handler, profile_item)
profile_menu.AppendSeparator()
profile_menu.Append(self.manage_profile_item)
profile_menu.Append(self.build_manage_profile_item())
return profile_menu

def build_name_conversation_menu(self) -> wx.Menu:
Expand Down

0 comments on commit df9cbd5

Please sign in to comment.