[Urwid] Set focus to top, middle or bottom item in Listbox

naglis at lavabit.com naglis at lavabit.com
Wed Jul 17 09:00:40 EDT 2013


Hi,
I'm fairly new to urwid and I'm trying to implement a vi-like navigation 
with keyboard shortcuts H, M, L where H sets focus to the top currently
visible item, M - to the middle one, and L - to the bottom one. However,
I'm struggling to get correct results. I've tried to extend my Listbox by 
adding a size attribute to it (I've seen this in a previous mailing list),
and then using it to calculate the position of the top, middle, bottom
currently visible item. However, this method fails if a list item
occupies more than on line on the screen.

I was wondering if someone else had solved this problem or has any tip
about how this can be done correctly.

Thanks in advance,
Naglis







More information about the Urwid mailing list