summaryrefslogtreecommitdiff
path: root/urwid
diff options
context:
space:
mode:
authorIan Ward <ian@excess.org>2012-10-10 15:27:45 -0400
committerIan Ward <ian@excess.org>2012-10-10 15:27:45 -0400
commit05182dfb128a24d0f5ec32b706fdfee96998d6c2 (patch)
treeca98870d3df49aca2d553b3e2189cc7c30ca8df1 /urwid
parentdca389bab9778d7b2b97459a02ac0ffdf2646613 (diff)
downloadurwid-05182dfb128a24d0f5ec32b706fdfee96998d6c2.tar.gz
new widget: WidgetDisable
--HG-- branch : feature-sphinx
Diffstat (limited to 'urwid')
-rw-r--r--urwid/__init__.py2
-rwxr-xr-xurwid/decoration.py21
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