Skip to content

Commit df9cbd5

Browse files
committed
fix: remove crash when calling the profile menu twice
closes #269
1 parent 58bcbad commit df9cbd5

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

basilisk/gui/main_frame.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,6 @@ def update_item_label_suffix(item: wx.MenuItem, suffix: str = "..."):
5454
item.SetItemLabel(item.GetItemLabel() + suffix)
5555

5656
menu_bar = wx.MenuBar()
57-
self.manage_profile_item = wx.MenuItem(
58-
id=wx.ID_ANY,
59-
# Translators: A label for a menu item to manage conversation profiles
60-
text=_("Manage conversation &profiles") + "...\tCtrl+Shift+P",
61-
)
62-
self.Bind(
63-
wx.EVT_MENU,
64-
self.on_manage_conversation_profiles,
65-
self.manage_profile_item,
66-
)
6757

6858
conversation_menu = wx.Menu()
6959

@@ -160,7 +150,7 @@ def update_item_label_suffix(item: wx.MenuItem, suffix: str = "..."):
160150
_("Manage &accounts") + "...\tCtrl+Shift+A",
161151
)
162152
self.Bind(wx.EVT_MENU, self.on_manage_accounts, manage_accounts_item)
163-
tool_menu.Append(self.manage_profile_item)
153+
tool_menu.Append(self.build_manage_profile_item())
164154
preferences_item = tool_menu.Append(wx.ID_PREFERENCES)
165155
self.Bind(wx.EVT_MENU, self.on_preferences, preferences_item)
166156
update_item_label_suffix(preferences_item, "...\tCtrl+,")
@@ -631,6 +621,19 @@ def show_dialog():
631621

632622
wx.CallAfter(show_dialog)
633623

624+
def build_manage_profile_item(self) -> wx.MenuItem:
625+
manage_profile_item = wx.MenuItem(
626+
id=wx.ID_ANY,
627+
# Translators: A label for a menu item to manage conversation profiles
628+
text=_("Manage conversation &profiles") + "...\tCtrl+Shift+P",
629+
)
630+
self.Bind(
631+
wx.EVT_MENU,
632+
self.on_manage_conversation_profiles,
633+
manage_profile_item,
634+
)
635+
return manage_profile_item
636+
634637
def build_profile_menu(self, event_handler) -> wx.Menu:
635638
"""
636639
Build the conversation profile menu.
@@ -642,7 +645,7 @@ def build_profile_menu(self, event_handler) -> wx.Menu:
642645
profile_item = profile_menu.Append(wx.ID_ANY, profile.name)
643646
self.Bind(wx.EVT_MENU, event_handler, profile_item)
644647
profile_menu.AppendSeparator()
645-
profile_menu.Append(self.manage_profile_item)
648+
profile_menu.Append(self.build_manage_profile_item())
646649
return profile_menu
647650

648651
def build_name_conversation_menu(self) -> wx.Menu:

0 commit comments

Comments
 (0)