diff options
author | Ian Ward <ian@excess.org> | 2012-10-10 15:27:45 -0400 |
---|---|---|
committer | Ian Ward <ian@excess.org> | 2012-10-10 15:27:45 -0400 |
commit | 05182dfb128a24d0f5ec32b706fdfee96998d6c2 (patch) | |
tree | ca98870d3df49aca2d553b3e2189cc7c30ca8df1 /urwid | |
parent | dca389bab9778d7b2b97459a02ac0ffdf2646613 (diff) | |
download | urwid-05182dfb128a24d0f5ec32b706fdfee96998d6c2.tar.gz |
new widget: WidgetDisable
--HG--
branch : feature-sphinx
Diffstat (limited to 'urwid')
-rw-r--r-- | urwid/__init__.py | 2 | ||||
-rwxr-xr-x | urwid/decoration.py | 21 |
2 files changed, 22 insertions, 1 deletions
diff --git a/urwid/__init__.py b/urwid/__init__.py index 5c494d7..899a4da 100644 --- a/urwid/__init__.py +++ b/urwid/__init__.py @@ -29,7 +29,7 @@ from urwid.widget import (FLOW, BOX, FIXED, LEFT, RIGHT, CENTER, TOP, MIDDLE, delegate_to_widget_mixin, WidgetWrapError, WidgetWrap) from urwid.decoration import (WidgetDecoration, WidgetPlaceholder, AttrMapError, AttrMap, AttrWrap, BoxAdapterError, BoxAdapter, PaddingError, - Padding, FillerError, Filler) + Padding, FillerError, Filler, WidgetDisable) from urwid.container import (GridFlowError, GridFlow, OverlayError, Overlay, FrameError, Frame, PileError, Pile, ColumnsError, Columns, WidgetContainerMixin) diff --git a/urwid/decoration.py b/urwid/decoration.py index feef781..09a2129 100755 --- a/urwid/decoration.py +++ b/urwid/decoration.py @@ -882,6 +882,27 @@ class Filler(WidgetDecoration): return self._original_widget.mouse_event((maxcol, maxrow-top-bottom), event, button,col, row-top, focus) +class WidgetDisable(WidgetDecoration): + """ + A decoration widget that disables interaction with the widget it + wraps. This widget always passes focus=False to the wrapped widget, + even if it somehow does become the focus. + """ + no_cache = ["rows"] + ignore_focus = True + + def selectable(self): + return False + def rows(self, size, focus=False): + return self._original_widget.rows(size, False) + def sizing(self): + return self._original_widget.sizing() + def pack(self, size, focus=False): + return self._original_widget.pack(size, False) + def render(self, size, focus=False): + canv = self._original_widget.render(size, False) + return CompositeCanvas(canv) + def normalize_align(align, err): """ Split align into (align_type, align_amount). Raise exception err |