[Urwid] Pop-ups in Urwid

Ian Ward ian at excess.org
Thu Oct 15 10:53:21 EDT 2009


I have had the design of a general way of doing pop-ups with Urwid
rolling around in my head for years, and while I wrote the supporting
canvas handling code I never presented a working pop-up implementation.

Andrew Psaltis reminded me of this on IRC, and so I decided to finally
put an example together.  This example works with 0.9.8 and later
versions of Urwid.

The pop-up is implemented in two parts: the PopUpTarget is a box widget
that, in this example, covers the whole screen.  This is the area that
pop-ups may appear in.  The second part is a custom widget that displays
a pop-up when a button is pressed (press space or enter, I haven't
enabled the mouse in this example yet)

When the pop-up is displayed, try resizing the screen to see how it
behaves.  Notice that it seems attached to the originating widget, but
if you shrink the screen enough it will move to try to keep its size intact.

I haven't included this code in Urwid yet because I'm not yet sure I
like the interface.  Suggestions are welcome.

Ian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: popup.py
Type: text/x-python
Size: 3374 bytes
Desc: not available
Url : http://lists.excess.org/pipermail/urwid/attachments/20091015/cd4d0c15/attachment.py 


More information about the Urwid mailing list