comparison urwid_satext/sat_widgets.py @ 56:22ab98a06492

GenericList: click/change signals fix
author Goffi <goffi@goffi.org>
date Tue, 16 Oct 2012 01:09:51 +0200
parents d34f2b0f68d3
children d493f95724a7
comparison
equal deleted inserted replaced
55:952859ec2d82 56:22ab98a06492
334 widget.setState(True, invisible=True) 334 widget.setState(True, invisible=True)
335 return 335 return
336 if selected: 336 if selected:
337 self.unselectAll(invisible=True) 337 self.unselectAll(invisible=True)
338 widget.setState(True, invisible=True) 338 widget.setState(True, invisible=True)
339 self._emit("click") 339 self._emit("change")
340 340
341 def __onClick(self, widget):
342 self._emit("click", widget)
341 343
342 def unselectAll(self, invisible=False): 344 def unselectAll(self, invisible=False):
343 for widget in self.content: 345 for widget in self.content:
344 if widget.getState(): 346 if widget.getState():
345 widget.setState(False, invisible) 347 widget.setState(False, invisible)
382 for option in new_values: 384 for option in new_values:
383 widget = self.option_type(option, self.align) 385 widget = self.option_type(option, self.align)
384 if not self.first_display and option in old_selected: 386 if not self.first_display and option in old_selected:
385 widget.setState(True) 387 widget.setState(True)
386 widgets.append(widget) 388 widgets.append(widget)
387 try: 389 for signal, callback in (('change', self.__onStateChange), ('click', self.__onClick)):
388 urwid.connect_signal(widget, 'change', self.__onStateChange) 390 try:
389 except NameError: 391 urwid.connect_signal(widget, signal, callback)
390 pass #the widget given doesn't support 'change' signal 392 except NameError:
393 pass #the widget given doesn't support the signal
391 self.content[:] = widgets 394 self.content[:] = widgets
392 if self.first_display and self.single and new_values and not self.no_first_select: 395 if self.first_display and self.single and new_values and not self.no_first_select:
393 self.content[0].setState(True) 396 self.content[0].setState(True)
394 display_widget = self.getDisplayWidget() 397 display_widget = self.getDisplayWidget()
395 self._set_w(display_widget) 398 self._set_w(display_widget)