Urwid
lastmod 2022-07-07created 2015-10-114 edits
Console user interface library for Python.
Minimal application
import urwid
txt = urwid.Text(u"Hello World")
fill = urwid.Filler(txt, 'top')
loop = urwid.MainLoop(fill)
loop.run()
Flow Widgets
Text
Handles formatted blocks of text and wraps to the next line when necessary.
Widgets like this are called "Flow Widgets" because they can be given a number of columns for sizing (in this case, the full screen width).
They then flow to fill as many rows as they need.
Box Widgets
Filler
Fills blank lines above or below a flow widget so that it can be displayed in a fixed number of rows.
This Filler aligns the text to the top of the screen and fills all the rows below with blank lines.
Widgets that are given both the number of columns and the number of rows they must be displayed in are called "Box Widgets".
MainLoop
MainLoop handles displaying widgets and accepting user input.
The widget passed to MainLoop is called the "Topmost Widget".
The topmost widget is used to render the whole screen, so it must be a box widget.
In this case the widgets cannot handle user input, so the program must be interrupted with ^C to exit.