Arcadie Cracan wrote on 2010-01-30 09:36:
>>
>> Finally it would also be better to separate the loop handling from the
>> dialog itself and make the dialog just another widget. I'll post again
>> when I have time to update the example to do this.
>>
>
> Done (sort of...). Look at the implementation of DialogDisplay.show(). The
> dialog now raises 2 kinds of exceptions: ChildDialogExit and MainDialogExit.
> If a ChildDialogExit is encountered, then the loop is "re-run" (is it correct
> to do this?).
I think we need to keep the loop in the user's code somehow. Twisted
has a way of passing in a generator that yeilds deferred objects when it
needs to wait, instead of writing a bunch of tiny functions that call
back to each other. I think we could do something similar with Urwid.
Something like:
def conversation_app(loop):
# initialize the display
create_conversation_widgets(loop)
# allow the user to introduce themselves
# and wait for them to click OK
dialog = ask_name_dialog(loop)
yield dialog
# if they gave a name, greet them
if dialog.name:
yield say_hello_user_dialog(loop, dialog.name)
Does this kind of interface make sense? I'm open to suggestions.
Ian
_______________________________________________
Urwid mailing list
[email protected]
http://lists.excess.org/mailman/listinfo/urwid