[Urwid] Strange behaviour of ListBox

jm at jm10.no-ip.com jm at jm10.no-ip.com
Sun Jul 23 14:19:45 EDT 2006


>> In fact, I don't pass the key to the top-level widget, because it is a
>> listbox
>> of 3 elements in Hachoir, not a frame. I found more simple to bypass it.
>>
>> Here is how I've fixed Hachoir :
> 
> Your fix will work as long as you don't put your body in a Columns or
> Padding widget (the width would be wrong).  Is there a reason you don't
> want to pass the keypress to the topmost widget?   You might find
> yourself chasing similar bugs later if you don't.
I don't want the body to lose the focus (once at the bottom at the body, the top
listbox selects another widget on 'down') and I don't know how to solve that.
Your answer seems to say it is possible... maybe like that (not yet committed) :

http://hachoir.python-hosting.com/file/hachoir/trunk/src/hachoir/ui/urwid/urwid_ui.py
--- src/hachoir/ui/urwid/urwid_ui.py    (revision 449)
+++ src/hachoir/ui/urwid/urwid_ui.py    (working copy)
@@ -408,2 +408,3 @@
     log = BoxAdapter(ListBox(msgs[1]), 0)
+    log.selectable = lambda: False
     top = ListBox((body, AttrWrap(sep, 'sep'), log))
@@ -438,3 +439,3 @@
                     else:
-                        body.keypress(size[:1], e)
+                        top.keypress(size, e)
                 except AssertionError:


JM




More information about the Urwid mailing list