Ian Ward wrote: > Walter Mundt wrote: >> Ian Ward wrote: >>> It's a good start. I was hoping this could be done with >>> get_input_descriptors[1] and get_input_nonblocking[2] instead of using >>> threads. >>> >>> [1] http://excess.org/urwid/reference.html#Screen-get_input_descriptors >>> [2] http://excess.org/urwid/reference.html#Screen-get_input_nonblocking >> Done. Also, this version adds a handle_reactor parameter. If False, >> rather than looping the function simply returns a twisted Deferred that >> will trigger when the UI shuts down, whether via an ExitMainLoop call >> (callback True) or a different unhandled exception in one of the >> handlers passed in (errback). > > Great! That was fast, Walter :-) > > A couple final suggestions: twisted_main_loop needs a docstring > explaining what you said above, and the code should be written in a way > that I can add it to main_loop.py even on systems without twisted > installed - either only import twisted.(...) inside the functions that > need those symbols, or handle the ImportError and make twisted_main_loop > send a helpful error message. > > Ian
I have added your code with some modifications to the hg repo: https://excess.org/hg/urwid/file/2bd2ab311547/urwid/main_loop.py Some initial testing suggests that the error handling isn't quite behaving properly. I tried running: urwid.generic_main_loop(urwid.SolidFill('x')) and compared it to: urwid.twisted_main_loop(urwid.SolidFill('x')) The first one fails out when I press a key (solidfill can't handle keystrokes) or ^C, but the second one doesn't quite do the same thing. Ian _______________________________________________ Urwid mailing list [email protected] http://lists.excess.org/mailman/listinfo/urwid
