Discussion:
[Urwid] simple overlay? (again?)
Christopher Trudeau
2013-01-13 15:15:35 UTC
Permalink
I apologize if this shows up twice, I didn't originally send it from the
account I signed up with and I think the list manager ignored it.

----------
I'm trying to add a "help" dialog box to my application so have been
fiddling with Overlay and PopUpLauncher, with little success with either.
With Overlay I've yet to be able to see an overlayed window, no exceptions,
just does nothing. With PopUpLauncher I've had similar problems, in
certain configurations I've managed to see a window but not been able to
get it to focus. I've looked at the examples, but they all seem to be
based on a simple underlying window with only a button, as soon as I try to
do something more complicated I get stuck.

Below is a simple version of what I'm trying to accomplish that is
structured in a similar vein to the larger program. Any hints on what I'm
doing wrong would be greatly appreciated. This version shows nothing at
all, debug statements confirm things are getting run and constructed (not
shown below) but nothing is shown.

def key_handler(key):
if key in ('q', 'Q'):
raise urwid.ExitMainLoop()
elif key in ('o', 'O'):
show_overlay();


def show_overlay():
text = urwid.Text(POPUP_TEXT)
pile = urwid.Pile([text, ])
urwid.Overlay(pile, outer, 'center', 50, 'middle', 50)


header = urwid.Text(('header', 'q=quit; o=overlay'))
roach = urwid.Text(ROACH)
fill = urwid.Filler(roach, 'top')
outer = urwid.Frame(fill, header=header)
loop = urwid.MainLoop(outer, palette,
unhandled_input=key_handler, pop_ups=True)
loop.run()

Thanks for your help.
--
Christopher Trudeau
ctrudeau at arSensa.com
(cell) 416-731-4304
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.excess.org/pipermail/urwid/attachments/20130113/cb6f2843/attachment.htm
Ian Ward
2013-01-13 16:09:39 UTC
Permalink
On Jan 13, 2013 10:15 AM, "Christopher Trudeau" <ctrudeau+urwid at arsensa.com>
Post by Christopher Trudeau
text = urwid.Text(POPUP_TEXT)
pile = urwid.Pile([text, ])
urwid.Overlay(pile, outer, 'center', 50, 'middle', 50)
Try replacing the last line with

loop.widget = urwid.Overlay(pile, outer,...)

Ian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.excess.org/pipermail/urwid/attachments/20130113/a9d6cd6f/attachment.htm
Christopher Trudeau
2013-01-14 21:05:06 UTC
Permalink
Thanks, that fixed it (well, after a bit of fudging -- I had to change the
widget to be based on a Filler so that MainLoop could point to it). I
appreciate the help.

Now, I'm going to impose a bit and ask: why'd it work? Maybe I'm not quite
understanding what the Overlay is for. While I'm pestering, what about
PopUpLauncher? Is it just an abstraction of Overlay or is something else
going on?
...ct
Post by Ian Ward
On Jan 13, 2013 10:15 AM, "Christopher Trudeau" <
Post by Christopher Trudeau
text = urwid.Text(POPUP_TEXT)
pile = urwid.Pile([text, ])
urwid.Overlay(pile, outer, 'center', 50, 'middle', 50)
Try replacing the last line with
loop.widget = urwid.Overlay(pile, outer,...)
Ian
_______________________________________________
Urwid mailing list
Urwid at lists.excess.org
http://lists.excess.org/mailman/listinfo/urwid
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.excess.org/pipermail/urwid/attachments/20130114/753caaa6/attachment.htm
Loading...