[Twisted-Python] Twisted and Urwid

Christian Scharkus mail.sensenmann at googlemail.com
Sat Dec 27 13:08:18 EST 2008

Hi folks.

I've got a new question. After recongnising that the python bindings for
curses are not fully capable of displaying the unicode-chars I decided to
drop curses and shifted to urwid. Now I've got some basic questions in the
matter of urwid and twisted. As you may know I'm using a mvc-pattern and I
have not discovered a way to combine _and_ start urwid with twisted yet.
Maybe someone who already worked with urwid can give me a small hint.



class Input:
    def __init__(self,term):
        self.term = term
        self.size = self.term.get_cols_rows()
        self.input = urwid.Edit()
        self.filler = urwid.Filler(self.input)
        self.canvas = self.filler.render( self.size, focus=True )

    def fileno(self):
        return 0

    def logPrefix(self):
        return 'CursesClient'

    def doRead(self):
        keys = self.term.get_input_nonblocking()
        for key in keys:
            if key == 'window resize':
                self.size = self.term.get_cols_rows()
            elif key == 'enter':
                text = self.input.get_edit_text()
                self.filler.keypress(self.size, key)

term = urwid.raw_display.Screen()
term.run_wrapper(lambda: Input(term))

Traceback (most recent call last):
  File "./keckz.py", line 44, in <module>
    f.startKeckz(f.host, f.view)
  File "./keckz.py", line 38, in startKeckz
  File "/home/arch/keckz/trunk/controllerKeckz.py", line 13, in __init__
    self.view = interface(self)
  File "/home/arch/keckz/trunk/urwid_cli.py", line 21, in __init__
    self.term.run_wrapper(lambda: Input(self.term))
  File "/usr/lib/python2.6/site-packages/urwid/raw_display.py", line
212, in run_wrapper
    return fn()
  File "/home/arch/keckz/trunk/urwid_cli.py", line 21, in <lambda>
    self.term.run_wrapper(lambda: Input(self.term))
  File "/home/arch/keckz/trunk/urwid_cli.py", line 55, in __init__
  File "/usr/lib/python2.6/site-packages/urwid/raw_display.py", line
579, in draw_screen
    assert self.palette.has_key(a), `a`
AssertionError: None
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20081227/f183a48a/attachment.htm 

More information about the Twisted-Python mailing list