[Twisted-Python] Twisted and Urwid
Christian Scharkus
mail.sensenmann at googlemail.com
Sat Dec 27 11:08:18 MST 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.
Code:
http://codepad.org/0Hlvmp1b
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 )
self.term.draw_screen(self.size,self.canvas)
reactor.addReader(self)
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()
controller.sendMsg('dev',text)
self.input.set_edit_text('')
else:
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
controllerKeckz.Kekzcontroller(View).startConnection(host,23002)
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__
self.term.draw_screen(self.size,self.canvas)
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: </pipermail/twisted-python/attachments/20081227/f183a48a/attachment.html>
More information about the Twisted-Python
mailing list