comparison urwid_satext/sat_widgets.py @ 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 1cdf4a00b68d
children bf38c1c0db3b
comparison
equal deleted inserted replaced
112:b3e8edbe0a1e 113:77ccc1dd2261
1094 self._showSelected() #if we are on the menu, we update it 1094 self._showSelected() #if we are on the menu, we update it
1095 1095
1096 def removeMenu(self, menu_id): 1096 def removeMenu(self, menu_id):
1097 del self.menu_items[menu_id] 1097 del self.menu_items[menu_id]
1098 if self.selected == menu_id: 1098 if self.selected == menu_id:
1099 self.selected = self.menu_items.items[0] if self.menu_items else None 1099 try:
1100 self.selected = self.menu_items.iterkeys().next()
1101 except StopIteration:
1102 self.selected = None
1100 self._showSelected() 1103 self._showSelected()
1101 1104
1102 def checkShortcuts(self, key): 1105 def checkShortcuts(self, key):
1103 for menu_item in self.menu_items.values(): 1106 for menu_item in self.menu_items.values():
1104 key = menu_item.widget.checkShortcuts(key) 1107 key = menu_item.widget.checkShortcuts(key)
1425 if not invisible: 1428 if not invisible:
1426 self._emit('click') 1429 self._emit('click')
1427 1430
1428 def _appendButton(self, name, selected=False): 1431 def _appendButton(self, name, selected=False):
1429 """Append a button to the frame header, and link it to the page change method. 1432 """Append a button to the frame header, and link it to the page change method.
1430 1433
1431 @param name (unicode): button name 1434 @param name (unicode): button name
1432 @param selected (bool): set to True to select this tab 1435 @param selected (bool): set to True to select this tab
1433 """ 1436 """
1434 button = CustomButton(name, self._buttonClicked, left_border = '', right_border=' | ') 1437 button = CustomButton(name, self._buttonClicked, left_border = '', right_border=' | ')
1435 self._buttons_cont.addWidget(button, button.getSize()) 1438 self._buttons_cont.addWidget(button, button.getSize())