attached an idea that comes to me about dialogs, but sadly it does not
work, may you can help me to investigate why. what is nice about this
idea is that a dialog freeze the normal program execution the following
logic could be implemented:

        dialog = YesNoDialog()
        ret = dialog.run()
        if ret = 'yes':
                ...
        elif ret == 'no':
                ...
import urwid
from urwid import raw_display

def dialog():
    def quit(key):
        raise urwid.ExitMainLoop()
    loop = urwid.MainLoop(widget2, palette, screen,
                          unhandled_input=quit, event_loop=event)
    loop.run()

def inpt(key):
    txt1.set_text(repr(key))
    if key == 'enter':
        dialog()
        txt1.set_text('dialog closed')
    elif key == 'q':
        raise urwid.ExitMainLoop()

screen = raw_display.Screen()
palette = [('normal', 'white', 'black'),
           ('focus', 'black', 'white')]
txt1 = urwid.Text(u'hello world')
widget1 = urwid.Filler(txt1)
widget2 = urwid.Filler(urwid.Text(u'ciao mondo'))
event = urwid.SelectEventLoop()
loop = urwid.MainLoop(widget1, palette, screen, unhandled_input=inpt,
                      event_loop=event)
loop.run()
_______________________________________________
Urwid mailing list
[email protected]
http://lists.excess.org/mailman/listinfo/urwid

Reply via email to