[Urwid] DialogBox

Muhammad Ammar mammar at gmail.com
Wed Jul 14 00:24:23 EDT 2010

Hi All,

I have recently started working on urwid and currently studying and playing
with documentation, source code and examples. Currently i am learning to use
dialogboxes, and i came to know that radiolist and checklist dialog boxes
"OK" and "Cancel" buttons aren't responding to key(left/right/down) events.
I made the following quick changes(don't know good or bad) and they are
working now.

Following is the diff of changes

--- dialog_org.py    2010-01-25 17:29:53.000000000 +0500
+++ dialog_new.py    2010-07-14 09:07:37.137528163 +0500
@@ -43,7 +43,8 @@
         ('focustext','light gray','dark blue'),

-    def __init__(self, text, height, width, body=None):
+    def __init__(self, text, height, width, body=None, un_key=None):
+        self.un_key=un_key
         width = int(width)
         if width <= 0:
             width = ('relative', 80)
@@ -97,7 +98,7 @@
         raise DialogExit(button.exitcode)

     def main(self):
-        self.loop = urwid.MainLoop(self.view, self.palette)
+        self.loop = urwid.MainLoop(self.view, self.palette,
         except DialogExit, e:
@@ -174,11 +175,12 @@

         lb = urwid.ListBox(l)
         lb = urwid.AttrWrap( lb, "selectable" )
-        DialogDisplay.__init__(self, text, height, width, lb )
+        DialogDisplay.__init__(self, text, height, width, lb,

-    def unhandled_key(self, size, k):
+#    def unhandled_key(self, size, k):    #don't know what value should be
passed as size
+    def unhandled_key(self, k):
         if k in ('up','page up'):
         if k in ('down','page down'):
@@ -187,7 +189,7 @@
             # pass enter to the "ok" button
-            self.view.keypress( size, k )
+            #self.view.keypress( size, k )

     def on_exit(self, exitcode):
         """Print the tag of the item selected."""

I also attached the dialog.py with my changes.

second thing i want to know about is how to make dialogboxes independent, by
independent i mean how to display a dialogbox on an already running gui. for
example, my gui application is running and i want to display
notifications/messages to user using dialogbox, so what i need is dialogbox
should appear on my already running gui instead of drawing a new screen and
then showing the dialog box, this is what currently happening.

I need a start point on how to make dialogboxes independent(or whatever you

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.excess.org/pipermail/urwid/attachments/20100714/a330eb4e/attachment.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dialog_new.py
Type: application/octet-stream
Size: 10530 bytes
Desc: not available
Url : http://lists.excess.org/pipermail/urwid/attachments/20100714/a330eb4e/attachment.obj 

More information about the Urwid mailing list