My program is split into 4 sections. One section is a constant-size section of various widgets, and the other 3 are list boxes.
If I set rows
to 15, on this screen size, the program will crash. Also, if it is set to 5, then space is wasted that could be used to show more elements in list box 3.
What can I do to let 3 shrink and prevent crashes if the screen is not big enough so that 4 takes up > 50% of the vertical space? Also, if possible, how can I make 3 take up extra vertical space if it is available on a taller screen? Thank you.
What I've tried: explicitly setting weights, box/flow wrapper
import urwid
rows = 5
listbox1 = urwid.ListBox(urwid.SimpleFocusListWalker([]))
listbox2 = urwid.ListBox(urwid.SimpleFocusListWalker([]))
listbox3 = urwid.ListBox(urwid.SimpleFocusListWalker([]))
fixedSize = urwid.Pile([urwid.Text(f'Hello {x}') for x in range(rows)])
linebox1 = urwid.LineBox(listbox1, title="1")
linebox2 = urwid.LineBox(listbox2, title="2")
linebox3 = urwid.LineBox(listbox3, title="3")
linebox4 = urwid.LineBox(fixedSize, title="4")
print(linebox3)
layout = urwid.Columns([
urwid.Pile([
linebox1,
linebox2
]),
urwid.Pile([
linebox3,
linebox4
])
])
master = urwid.Frame(body=layout)
loop = urwid.MainLoop(master)
loop.run()