Dominic LoBue wrote:
> Ian,
> 
> I found a weird bug with listboxes snapping to an odd location in the
> middle of a large selectable widget.
> 
> The setup:
> Listbox (maxcol, maxrow): (115, 31)
> 
> The contents of the listbox:
> widget 0: selectable, 1 row.
> widget 1: not selectable, 1 row
> widget 2: selectable, 55 rows
> widget 3: not selectable, 1 row
> (there's more widgets, in my setup, but they are of no consequence).
> 
> Steps:
> Scroll upwards so widget 0 is in focus.
> Press down once.
> 
> Result:
> The bottom of widget 2 is at the bottom of the screen, and the top
> half of the widget is scrolled off screen.

Did you look at test_urwid.py?  I've got pages of unit tests in there
that look like this under ListBoxKeypressTest.  It appears I somehow
missed this one case though.

> Expected result:
> Focus moves to widget 2 and no scrolling takes place.
> 
> 
> Attached is a patch which fixes the problem for me.

That's a reasonable fix, but I wonder if it should snap to the top of
the widget in this case instead.

The scrolling behaviour would usually bring the whole widget into view,
but with this change as soon as a widget is one line longer than the
ListBox it only brings a single line in.  I think it makes more sense to
have it scroll a maximum of the full height (in effect snapping the top)
because that is more alike what happens on the other side of this edge case.

This might not be what you need for your program, and I want to decouple
the scrolling behaviour from the ListBox at some point.  That way you
can have the exact behaviour you want, and it will reduce the amount of
code I need to write to create a horizontal list box.

Ian

_______________________________________________
Urwid mailing list
[email protected]
http://lists.excess.org/mailman/listinfo/urwid

Reply via email to