Quantcast
Viewing all articles
Browse latest Browse all 14069

Does the Python rich module provide scroll bars?

I'm creating a live table that gets updated every 60 seconds. The number of rows returned is variable and the size of the terminal is, of course, variable as well since it depends on what the user resizes it to.

The issue is quite simply that when the number of rows of data exceeds the available window space, data is currently hidden and there does not seem to be any way of viewing it.

As a simple example you can run the following code in a window with less than 30 lines on view:

    import time    import rich.live    import rich.table    table = rich.table.Table()    table.add_column("Row ID")    table.add_column("Description")    table.add_column("Level")    with rich.live.Live(table):        for row in range(30):            # update the renderable internally            table.add_row(f"{row}", f"description {row}", f"level {row}")        time.sleep(40000)  # arbitrary delay for this example.

It displays as many lines as your allow for, but no more and you cannot see the last few lines.

Is it possible to add a scroll bar to tables?

I've searched the docs online but there's no mention of scrollbars anywhere, which leads me to think that it's not possible, which surprises me given that scrollbars have been a UI staple for decades.


Viewing all articles
Browse latest Browse all 14069

Trending Articles