diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2011-10-01 21:14:50 +0100 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2011-10-01 21:14:50 +0100 |
commit | 7a431af0d8418a89fd4cbee19b9986c754ae6d8e (patch) | |
tree | f80b8ea2ada0b55a717375051e1a512978acdec3 /alot | |
parent | e3c3e5b4b49cf08035aa93611960577beeec8a0f (diff) |
add DialogBox widget
that decorates a widget with a box with title
Diffstat (limited to 'alot')
-rw-r--r-- | alot/widgets.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/alot/widgets.py b/alot/widgets.py index 092a414a..ab19827f 100644 --- a/alot/widgets.py +++ b/alot/widgets.py @@ -28,6 +28,30 @@ from helper import tag_cmp import message +class DialogBox(urwid.WidgetWrap): + def __init__(self, body, title, bodyattr=None, titleattr=None): + self.body = urwid.LineBox(body) + self.title = urwid.Text(title) + if titleattr is not None: + self.title = urwid.AttrMap(self.title, titleattr) + if bodyattr is not None: + self.body = urwid.AttrMap(self.body, bodyattr) + + box = urwid.Overlay(self.title, self.body, + align='center', + valign='top', + width=len(title), + height=None, + ) + urwid.WidgetWrap.__init__(self, box) + + def selectable(self): + return self.body.selectable() + + def keypress(self, size, key): + return self.body.keypress(size, key) + + class ThreadlineWidget(urwid.AttrMap): def __init__(self, tid, dbman): self.dbman = dbman |