I'd like to implement some hinting as to whether there remains items below or above the list of visible items in an urwid.ListBox
when I scroll it up or down. The 'scroll down' hint should appear only when there remains items after the last visible item and it should disappear when the last, visible item is the last item in the list. The reverse applies with the 'scroll up' hint.
I then need to know how many visible items there is in the list. Is there a way to retrieve the number of visible items in a list box, which I suppose is equal to the height of the list box, right?
Here's a starting point of what I'd like to check:
# This example is based on https://cmsdk.com/python/is-there-a-focus-changed-event-in-urwid.html
import urwid
def callback():
index = str(listbox.get_focus()[1])
debug.set_text("Index of selected item: " + index)
captions = "A B C D E F".split()
debug = urwid.Text("Debug")
items = [urwid.Button(caption) for caption in captions]
walker = urwid.SimpleListWalker(items)
listbox = urwid.ListBox(walker)
urwid.connect_signal(walker, "modified", callback)
frame = urwid.Frame(body=listbox, header=debug)
urwid.MainLoop(frame).run()
The idea is to know if the listbox is fully visible within the frame when the terminal window is shrunk or not tall enough to display everything, i.e. frame.height >= listbox.height
.