Hi Cary.<br><br>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.<br>
<br><div class="gmail_quote">2008/12/28 Cary Hull <span dir="ltr">&lt;<a href="mailto:cary.hull@gmail.com">cary.hull@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Did you look at this?<br>
<a href="http://excess.org/article/2008/09/urwid-gets-twisted-support/" target="_blank">http://excess.org/article/2008/09/urwid-gets-twisted-support/</a><br>
<br>
Otherwise it looks like the error you are seeing there is due to not<br>
setting up a palette.<br>
<br>
-Cary<br>
<div><div></div><div class="Wj3C7c"><br>
On Sat, Dec 27, 2008 at 10:08 AM, Christian Scharkus<br>
&lt;<a href="mailto:mail.sensenmann@googlemail.com">mail.sensenmann@googlemail.com</a>&gt; wrote:<br>
&gt; Hi folks.<br>
&gt;<br>
&gt; I&#39;ve got a new question. After recongnising that the python bindings for<br>
&gt; curses are not fully capable of displaying the unicode-chars I decided to<br>
&gt; drop curses and shifted to urwid. Now I&#39;ve got some basic questions in the<br>
&gt; matter of urwid and twisted. As you may know I&#39;m using a mvc-pattern and I<br>
&gt; have not discovered a way to combine _and_ start urwid with twisted yet.<br>
&gt; Maybe someone who already worked with urwid can give me a small hint.<br>
&gt;<br>
&gt; Code:<br>
&gt;<br>
&gt; <a href="http://codepad.org/0Hlvmp1b" target="_blank">http://codepad.org/0Hlvmp1b</a><br>
&gt;<br>
&gt; class Input:<br>
&gt; &nbsp; &nbsp; def __init__(self,term):<br>
&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; self.term = term<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; self.size = self.term.get_cols_rows()<br>
&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; self.input = urwid.Edit()<br>
&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; self.filler = urwid.Filler(self.input)<br>
&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; self.canvas = self.filler.render( self.size, focus=True )<br>
&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; self.term.draw_screen(self.size,self.canvas)<br>
&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; reactor.addReader(self)<br>
&gt;<br>
&gt; &nbsp; &nbsp; def fileno(self):<br>
&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; return 0<br>
&gt;<br>
&gt; &nbsp; &nbsp; def logPrefix(self):<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; return &#39;CursesClient&#39;<br>
&gt;<br>
&gt;<br>
&gt; &nbsp; &nbsp; def doRead(self):<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; keys = self.term.get_input_nonblocking()<br>
&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; for key in keys:<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if key == &#39;window resize&#39;:<br>
&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.size = self.term.get_cols_rows()<br>
&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elif key == &#39;enter&#39;:<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text = self.input.get_edit_text()<br>
&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; controller.sendMsg(&#39;dev&#39;,text)<br>
&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.input.set_edit_text(&#39;&#39;)<br>
&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.filler.keypress(self.size, key)<br>
&gt;<br>
&gt;<br>
&gt; term = urwid.raw_display.Screen()<br>
&gt;<br>
&gt; term.run_wrapper(lambda: Input(term))<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; Traceback (most recent call last):<br>
&gt; &nbsp; File &quot;./keckz.py&quot;, line 44, in &lt;module&gt;<br>
&gt;<br>
&gt; &nbsp; &nbsp; f.startKeckz(f.host, f.view)<br>
&gt;<br>
&gt; &nbsp; File &quot;./keckz.py&quot;, line 38, in startKeckz<br>
&gt;<br>
&gt; &nbsp; &nbsp; controllerKeckz.Kekzcontroller(View).startConnection(host,23002)<br>
&gt;<br>
&gt; &nbsp; File &quot;/home/arch/keckz/trunk/controllerKeckz.py&quot;, line 13, in __init__<br>
&gt;<br>
&gt; &nbsp; &nbsp; self.view = interface(self)<br>
&gt;<br>
&gt; &nbsp; File &quot;/home/arch/keckz/trunk/urwid_cli.py&quot;, line 21, in __init__<br>
&gt;<br>
&gt; &nbsp; &nbsp; self.term.run_wrapper(lambda: Input(self.term))<br>
&gt;<br>
&gt; &nbsp; File &quot;/usr/lib/python2.6/site-packages/urwid/raw_display.py&quot;, line 212, in<br>
&gt; run_wrapper<br>
&gt;<br>
&gt; &nbsp; &nbsp; return fn()<br>
&gt; &nbsp; File &quot;/home/arch/keckz/trunk/urwid_cli.py&quot;, line 21, in &lt;lambda&gt;<br>
&gt;<br>
&gt; &nbsp; &nbsp; self.term.run_wrapper(lambda: Input(self.term))<br>
&gt;<br>
&gt; &nbsp; File &quot;/home/arch/keckz/trunk/urwid_cli.py&quot;, line 55, in __init__<br>
&gt;<br>
&gt; &nbsp; &nbsp; self.term.draw_screen(self.size,self.canvas)<br>
&gt;<br>
&gt; &nbsp; File &quot;/usr/lib/python2.6/site-packages/urwid/raw_display.py&quot;, line 579, in<br>
&gt; draw_screen<br>
&gt;<br>
&gt; &nbsp; &nbsp; assert self.palette.has_key(a), `a`<br>
&gt;<br>
&gt; AssertionError: None<br>
&gt;<br>
&gt;<br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; Twisted-Python mailing list<br>
&gt; <a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
&gt; <a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
&gt;<br>
&gt;<br>
<font color="#888888"><br>
<br>
<br>
--<br>
01100011 01100001 01110010 01111001<br>
<br>
_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
</font></blockquote></div><br>