From 7a431af0d8418a89fd4cbee19b9986c754ae6d8e Mon Sep 17 00:00:00 2001 From: Patrick Totzke Date: Sat, 1 Oct 2011 21:14:50 +0100 Subject: add DialogBox widget that decorates a widget with a box with title --- alot/widgets.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'alot') 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 -- cgit v1.2.3