[Urwid] Resizing listboxes and status of urwid

Keith Edmunds kae at midnighthax.com
Sat Mar 8 08:47:51 EST 2008


If I create a listbox that is long enough such that it isn't all
displayed, and then resize the window to be smaller, everything seems to
work just fine. If I resize the window to be larger, the previously
undisplayed items (or some of them) should become visible, but they don't.
Clearly I'm missing something! Sample code below.

On an unrelated topic, what is the status of urwid? There seem to have
been no releases since June 2007, and the promising start to the urwid
manual appears to have been left unfinished. This isn't a criticism, by
the way: I'm just trying to establish what, if any, future urwid has.

Thanks,
Keith

Sample code:

--------------------------------------------------------------------------------
#!/usr/bin/python

import urwid
import urwid.curses_display

def run():

    cols, rows = ui.get_cols_rows()

    textlist = [urwid.Text("item_" + str(x)) for x in range(50)]
    listwalker = urwid.SimpleListWalker(textlist)
    listbox = urwid.ListBox(listwalker)
    top = urwid.Frame(listbox)

    size = ui.get_cols_rows()

    while True:
	canvas = top.render(size, focus=True)
	ui.draw_screen( size, canvas )

	keys = ui.get_input()
	if "q" in keys or "Q" in keys:
	    break
	if "window resize" in keys:
	    cols, rows = ui.get_cols_rows()

#########################
if __name__ == "__main__":
    
    ui = urwid.curses_display.Screen()
    ui.run_wrapper(run)

# vi:tw=0:wm=0:nowrap:ai:noet:ts=8:softtabstop=4:shiftwidth=4
--------------------------------------------------------------------------------




More information about the Urwid mailing list