[Urwid] urwid and twisted reactor
Ilpo Nyyssönen
iny+dev at iki.fi
Thu Jul 6 01:36:17 EDT 2006
markus espenhain <me at cubeball.net> writes:
> Ilpo Nyyssönen wrote:
>> I basically run it like this:
>>
>> tui = urwid_display.Screen()
>> screen = Screen(tui)
>> reactor.addReader(screen)
>> tui.run_wrapper(reactor.run)
> thanks for the reply - can you provide some code of your Screen class
> -
> i found the twisted curses example but i'm still confused about the
> fake fd for urwid
Yes, the curses example is the base for it.
I have a function there that is called with
reactor.callWhenRunning(...) and it creates the urwid stuff to be put to the
screen and then displays it. It returns a deferred and I call the
callback of it when I want to quit the thing.
Another essential part is the implementation of the doRead() method.
It calls currently get_input() and then processes the keys got and
finally redisplays the urwid stuff.
The fake fd thing is just like in the curses example. It is a class
that has a fileno() method returning 0 (for stdin) and the doRead()
method for doing the reading. See the documentation for the
reactor.addReader(...) method. Essentially it works so that the
reactor checks the fd 0 (stdin) with select to notice when there is
input ready and then calls the doRead() when there is something. We
then just use urwid to put stuff visible and to read the input.
--
Ilpo Nyyssönen # biny # /* :-) */
More information about the Urwid
mailing list