Discussion:
[Urwid] Scrollbar support?
Joshua Harlow
2013-12-16 03:24:30 UTC
Permalink
Hi all urwid devs,

Thanks for the great library!

It has allowed me to create a few useful tools @
https://github.com/harlowja/gerrit_view/

One feature that I am lacking though is a vertical scrollbar (it would be
nice to know the current scroll status of a listbox for example, in said
GUIs at the above github site). I have seen that there are/were a few
attempts at it (but none seem to be in the offical repo). Has there been
any progress there, maybe a release with hbar and vbar support??

Thoughts??

-Josh
--
--
facebook.com/jshharlow <http://www.facebook.com/jshharlow>
flickr.com/jshharlow
YIM: jshharlow
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.excess.org/pipermail/urwid/attachments/20131215/13e2de62/attachment.htm
Ian Ward
2013-12-25 00:14:37 UTC
Permalink
Thanks Joshua,

It's pretty easy to make a scroll bar to handle a specific use case.
You can make a 1-column wide Pile that uses SolidFill for the bar and
background regions.

It's quite a bit harder to make one for the general case. ListBox
supports unlimited contents, so you would have to limit the list
walkers you can use. Next you have to decide if the position within a
list is sufficient or if you need to know the number of actual rows of
each item. For some lists the bar would perform badly without the
exact number of rows. If you need the exact rows then that means you
need to calculate the width of every item in the list, which for long
lists is going to be quite slow, and would need to be re-done every
time the width of the ListBox changes.

Have you considered just having markers that indicates whether you can
scroll up and/or down? There's an ends_visible() method on ListBox
just for this purpose.

Another approach is to show your position within the list in a footer,
the way less or vim do.

Ian
Post by Joshua Harlow
Hi all urwid devs,
Thanks for the great library!
https://github.com/harlowja/gerrit_view/
One feature that I am lacking though is a vertical scrollbar (it would be
nice to know the current scroll status of a listbox for example, in said
GUIs at the above github site). I have seen that there are/were a few
attempts at it (but none seem to be in the offical repo). Has there been any
progress there, maybe a release with hbar and vbar support??
Thoughts??
-Josh
--
--
facebook.com/jshharlow
flickr.com/jshharlow
YIM: jshharlow
_______________________________________________
Urwid mailing list
Urwid at lists.excess.org
http://lists.excess.org/mailman/listinfo/urwid
Joshua Harlow
2013-12-25 04:47:50 UTC
Permalink
Cool, thanks ian,

I've done a little bit of both of the methods u described (position in
footer, showing there are more entries on a following screen...) using
piles and solidfill (similar to linebox in a way).

Let me look into the ends_visible(), wasn't aware of that one.

If u avoid the determining the number of rows in the list box (the visual
number of rows) but instead just attach the scrollbar to the current focus
item index in the listbox then wouldn't this be easier?

For an item which has focus at index 5 of a listbox of length 10 then u
know u are 50%, even though this isn't (may not be) a direct connection to
the visual number of rows (depending on what is contained in the list box)
it would be a connection to being 50% through the listbox. Seems like there
could be multiple implementations of a scrollbar, one implementation could
be via this method, another one can be the more expensive visual number of
rows and another could just be an infinite scrollbar (think similar to how
websites dynamically add content to a webpage, and the scrollbar has to
adjust for this).

Anyways, merry xmas :-P
Post by Ian Ward
Thanks Joshua,
It's pretty easy to make a scroll bar to handle a specific use case.
You can make a 1-column wide Pile that uses SolidFill for the bar and
background regions.
It's quite a bit harder to make one for the general case. ListBox
supports unlimited contents, so you would have to limit the list
walkers you can use. Next you have to decide if the position within a
list is sufficient or if you need to know the number of actual rows of
each item. For some lists the bar would perform badly without the
exact number of rows. If you need the exact rows then that means you
need to calculate the width of every item in the list, which for long
lists is going to be quite slow, and would need to be re-done every
time the width of the ListBox changes.
Have you considered just having markers that indicates whether you can
scroll up and/or down? There's an ends_visible() method on ListBox
just for this purpose.
Another approach is to show your position within the list in a footer,
the way less or vim do.
Ian
Post by Joshua Harlow
Hi all urwid devs,
Thanks for the great library!
https://github.com/harlowja/gerrit_view/
One feature that I am lacking though is a vertical scrollbar (it would be
nice to know the current scroll status of a listbox for example, in said
GUIs at the above github site). I have seen that there are/were a few
attempts at it (but none seem to be in the offical repo). Has there been
any
Post by Joshua Harlow
progress there, maybe a release with hbar and vbar support??
Thoughts??
-Josh
--
--
facebook.com/jshharlow
flickr.com/jshharlow
YIM: jshharlow
_______________________________________________
Urwid mailing list
Urwid at lists.excess.org
http://lists.excess.org/mailman/listinfo/urwid
_______________________________________________
Urwid mailing list
Urwid at lists.excess.org
http://lists.excess.org/mailman/listinfo/urwid
--
--
facebook.com/jshharlow <http://www.facebook.com/jshharlow>
flickr.com/jshharlow
YIM: jshharlow
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.excess.org/pipermail/urwid/attachments/20131224/612c6aec/attachment.html
Continue reading on narkive:
Loading...