changeset 113:77ccc1dd2261

MenuRoller: fixed crash when deleting a displayed menu
author Goffi <goffi@goffi.org>
date Mon, 09 Nov 2015 15:36:39 +0100
parents b3e8edbe0a1e
children bf38c1c0db3b
files urwid_satext/sat_widgets.py
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/urwid_satext/sat_widgets.py	Fri Sep 25 18:32:32 2015 +0200
+++ b/urwid_satext/sat_widgets.py	Mon Nov 09 15:36:39 2015 +0100
@@ -1096,7 +1096,10 @@
     def removeMenu(self, menu_id):
         del self.menu_items[menu_id]
         if self.selected == menu_id:
-            self.selected = self.menu_items.items[0] if self.menu_items else None
+            try:
+                self.selected = self.menu_items.iterkeys().next()
+            except StopIteration:
+                self.selected = None
             self._showSelected()
 
     def checkShortcuts(self, key):
@@ -1427,7 +1430,7 @@
 
     def _appendButton(self, name, selected=False):
         """Append a button to the frame header, and link it to the page change method.
-        
+
         @param name (unicode): button name
         @param selected (bool): set to True to select this tab
         """