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:
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
Did you look at this? http://excess.org/article/2008/09/urwid-gets-twisted-support/
Otherwise it looks like the error you are seeing there is due to not setting up a palette.
-Cary
On Sat, Dec 27, 2008 at 10:08 AM, Christian Scharkus mail.sensenmann@googlemail.com wrote:
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:
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
Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Hi Cary.
I have seen it but I would prefer just to add my Input-Class as a Reader to the reactor instead of using the twisted_main_loop. I have just the problem that I have no idea how I make urwid start in the beginning.
2008/12/28 Cary Hull cary.hull@gmail.com
Did you look at this? http://excess.org/article/2008/09/urwid-gets-twisted-support/
Otherwise it looks like the error you are seeing there is due to not setting up a palette.
-Cary
On Sat, Dec 27, 2008 at 10:08 AM, Christian Scharkus mail.sensenmann@googlemail.com wrote:
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:
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
Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
-- 01100011 01100001 01110010 01111001
Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
On Sun, 28 Dec 2008 17:28:14 +0100, Christian Scharkus mail.sensenmann@googlemail.com wrote:
Hi Cary.
I have seen it but I would prefer just to add my Input-Class as a Reader to the reactor instead of using the twisted_main_loop. I have just the problem that I have no idea how I make urwid start in the beginning.
Perhaps that question would be more appropriately put to the urwid mailing list.
Jean-Paul
It is already there. But why don't ask at the other projects mailing list too?
2008/12/28 Jean-Paul Calderone exarkun@divmod.com
On Sun, 28 Dec 2008 17:28:14 +0100, Christian Scharkus < mail.sensenmann@googlemail.com> wrote:
Hi Cary.
I have seen it but I would prefer just to add my Input-Class as a Reader to the reactor instead of using the twisted_main_loop. I have just the problem that I have no idea how I make urwid start in the beginning.
Perhaps that question would be more appropriately put to the urwid mailing list.
Jean-Paul
Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python