Mercurial > libervia-backend
comparison sat_frontends/quick_frontend/quick_app.py @ 3159:30e08d904208
quick_frontend (app, widget): CagouWidget.onSelected is called when the widget is selected:
A property is now used to manage `selected_widget` in QuickApp, and widget's onSelected
method is called when suitable.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 09 Feb 2020 23:50:21 +0100 |
parents | 6032245c927e |
children | 9dc170635bee |
comparison
equal
deleted
inserted
replaced
3158:6032245c927e | 3159:30e08d904208 |
---|---|
299 if check_options is not None: | 299 if check_options is not None: |
300 self.options = check_options() | 300 self.options = check_options() |
301 else: | 301 else: |
302 self.options = None | 302 self.options = None |
303 | 303 |
304 # widget currently selected (must be filled by frontend) | 304 # see selected_widget setter and getter |
305 self.selected_widget = None | 305 self._selected_widget = None |
306 | 306 |
307 # listeners are callable watching events | 307 # listeners are callable watching events |
308 self._listeners = {} # key: listener type ("avatar", "selected", etc), | 308 self._listeners = {} # key: listener type ("avatar", "selected", etc), |
309 # value: list of callbacks | 309 # value: list of callbacks |
310 | 310 |
433 @return (iter[object]): iterable on visible widgets | 433 @return (iter[object]): iterable on visible widgets |
434 """ | 434 """ |
435 for w in self.visisble_widgets: | 435 for w in self.visisble_widgets: |
436 if isinstance(w, quick_widgets.QuickWidget): | 436 if isinstance(w, quick_widgets.QuickWidget): |
437 return w | 437 return w |
438 | |
439 @property | |
440 def selected_widget(self): | |
441 """widget currently selected | |
442 | |
443 This must be set by frontend using setter. | |
444 """ | |
445 return self._selected_widget | |
446 | |
447 @selected_widget.setter | |
448 def selected_widget(self, wid): | |
449 """Set the currently selected widget | |
450 | |
451 Must be set by frontend | |
452 """ | |
453 self._selected_widget = wid | |
454 try: | |
455 onSelected = wid.onSelected | |
456 except AttributeError: | |
457 pass | |
458 else: | |
459 onSelected() | |
438 | 460 |
439 # backend state management | 461 # backend state management |
440 | 462 |
441 @property | 463 @property |
442 def sync(self): | 464 def sync(self): |