Table of Contents
Overview
Reference
ProgressBar

Terminology
Topics
Display Attributes
- When a display attribute is
None
, it's considered as default
palette
is a list of (name, like_other_name)
or (name, foreground, background, mono, foreground_high, background_high)
mono
and foreground/background_high
values are optional
palette = [
('banner', 'black', 'light gray'),
('streak', 'black', 'dark red'),
('bg', 'black', 'dark blue'),
]
urwid.MainLoop(fill, palette)


- The topmost widget is always a box widget.


Pile
and ListBox
are both for stacking widgets vertically.
- Only
ListBox
can scroll widgets.
How-to
Implement tick loop
Handle signals

import urwid
palette = [('I say', 'default,bold', 'default', 'bold'),]
ask = urwid.Edit(('I say', u"What is your name?\n"))
reply = urwid.Text(u"")
button = urwid.Button(u'Exit')
div = urwid.Divider()
pile = urwid.Pile([ask, div, reply, div, button])
top = urwid.Filler(pile, valign='top')
def on_ask_change(edit, new_edit_text):
reply.set_text(('I say', u"Nice to meet you, %s" % new_edit_text))
def on_exit_clicked(button):
raise urwid.ExitMainLoop()
urwid.connect_signal(ask, 'change', on_ask_change)
urwid.connect_signal(button, 'click', on_exit_clicked)
urwid.MainLoop(top, palette).run()
Links