[Urwid] Bug or improper usage?

Sascha Silbe sascha-ml-ui-urwid at silbe.org
Mon Mar 10 12:56:56 EDT 2008


Hi!

I'm trying to write a urwid backend for my UI abstraction layer [1]. 
While doing some simple tests, I've encountered an exception that might 
either be a bug or a misunderstanding in how to use urwid.

Steps to reproduce:
1. Run the attached Python script.
2. Press <cursor down>

The following traceback will be printed:

Traceback (most recent call last):
    File "./x.py", line 30, in ?
      ui.run_wrapper( run )
    File "/usr/lib/python2.4/site-packages/urwid/curses_display.py", 
line 202, in run_wrapper
      return fn()
    File "./x.py", line 28, in run
      fill.keypress( (cols, rows), k )
    File "/usr/lib/python2.4/site-packages/urwid/widget.py", line 1460, 
in keypress
      return self.body.keypress( (maxcol,), key )
    File "/usr/lib/python2.4/site-packages/urwid/widget.py", line 2380, 
in keypress
      if self.focus_item.move_cursor_to_coords(
    File "/usr/lib/python2.4/site-packages/urwid/widget.py", line 595, 
in move_cursor_to_coords
      pos = calc_pos( self.get_text()[0], trans, x, y )
    File "/usr/lib/python2.4/site-packages/urwid/util.py", line 592, in 
calc_pos
      pos = calc_line_pos( text, layout[row], pref_col )
    File "/usr/lib/python2.4/site-packages/urwid/util.py", line 566, in 
calc_line_pos
      if closest_sc is None or ( abs(pref_col-current_sc)
TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'


This only happens for the combination Button+Edit (in this order). Using 
the same widget twice or listing the Edit first works fine. Because of 
that, I suspect it's a bug, but since I haven't fully grasped urwids 
design yet, it might as well just work by chance in the other cases.


CU Sascha

[1] 
http://projects.silbe.org/permalink/en/i_7249a450%2d4b98%2d44a5%2da8a0%2dceefdfef7d5e_%2d%2d%3E.html

-- 
http://sascha.silbe.org/
http://www.infra-silbe.de/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x.py
Type: text/x-python
Size: 912 bytes
Desc: not available
Url : http://lists.excess.org/pipermail/urwid/attachments/20080310/ba3c68ab/attachment.py 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.excess.org/pipermail/urwid/attachments/20080310/ba3c68ab/attachment.pgp 


More information about the Urwid mailing list