Multiple ListBox columns in urwid

925 Views Asked by At

I am trying to build an interface as part of a console application that reads an output file and displays part of its contents in a window (split vertically) as a scrollable list. The user should be able to choose items from this list, which when selected show up in the adjacent window. Switching to this adjacent window and selecting items should then remove them. When the user hits 'Q' or some other appropriate keypress, the interface should exit and the choices are then available to the main program for further processing.

I am trying to build this using urwid. I can get the results to show up in a ListBox widget, but when I try to wrap this and a separate instance of a ListBox widget in a Columns widget, the program throws an error on calling the mainloop. Basically, something like this:

listbox1 = urwid.ListBox(urwid.SimpleListWalker[<lines>])
listbox2 = urwid.ListBox(urwid.SimpleListWalker[])

urwid.MainLoop(urwid.Columns([listbox1, listbox2])).run()

I then get:

AttributeError: 'listbox1' object has no attribute 'rows'

I guess because it is a 'flow' style widget it has no specified number of rows, and since the Columns object would be the top level widget, calls to render fail due to not being able to determine the overall size of the screen? If so, what is the best way to work around this?

EDIT: Can simply wrap the columns object in Frame without calling header or footer and get desired output.

0

There are 0 best solutions below