On Wed, Nov 25, 2009 at 1:02 PM, Ian Ward <[email protected]> wrote:
> 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
>

I suppose that's a fair point.

Attached is a new hg export. I changed the behavior to what you
suggested. In addition I added the boolean attribute _snap to the
listbox. When _snap is set to True, the listbox scrolling behavior
snaps to to selectable widgets. When _snap is set to False, it
doesn't.

Obviously not a perfect solution - the ideal would be to have the
scroller look for a "snap" attribute in the widget it is scrolling to,
and if that attribute is True, then snap. But I figured this was a
happy middle ground to get by until you separate scrolling from the
listbox like you wanted.

Dominic

Attachment: urwid-listbox_snap_fix.patch
Description: Binary data

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

Reply via email to