diff options
| author | Random User <rndusr@posteo.de> | 2016-12-21 14:19:46 +0100 |
|---|---|---|
| committer | Random User <rndusr@posteo.de> | 2016-12-21 14:19:46 +0100 |
| commit | 926546596d36b5961fe709fc9afbfd4d8bbbf348 (patch) | |
| tree | 435e96e59ade059a1416464419eccb99f6a35370 | |
| parent | 9a29c4ebd521ae0a3759d72b2ac330d7912289ef (diff) | |
| download | urwid-926546596d36b5961fe709fc9afbfd4d8bbbf348.tar.gz | |
Make ListBox.body a property
This lets us automatically call _invalidate() each time the list box's body is
set.
| -rw-r--r-- | urwid/listbox.py | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/urwid/listbox.py b/urwid/listbox.py index 5370e23..75d47b6 100644 --- a/urwid/listbox.py +++ b/urwid/listbox.py @@ -278,11 +278,7 @@ class ListBox(Widget, WidgetContainerMixin): widgets to be displayed inside the list box :type body: ListWalker """ - if getattr(body, 'get_focus', None): - self.body = body - else: - self.body = PollingListWalker(body) - + self.body = body try: connect_signal(self.body, "modified", self._invalidate) except NameError: @@ -310,6 +306,22 @@ class ListBox(Widget, WidgetContainerMixin): self.set_focus_valign_pending = None + def _get_body(self): + return self._body + + def _set_body(self, body): + if getattr(body, 'get_focus', None): + self._body = body + else: + self._body = PollingListWalker(body) + self._invalidate() + + body = property(_get_body, _set_body, doc=""" + a ListWalker subclass such as :class:`SimpleFocusListWalker` that contains + widgets to be displayed inside the list box + """) + + def calculate_visible(self, size, focus=False ): """ Returns the widgets that would be displayed in |
