3
palette = [('header', 'white', 'black'),
4
('reveal focus', 'black', 'dark cyan', 'standout'),]
5
content = urwid.SimpleListWalker([
6
urwid.AttrMap(w, None, 'reveal focus') for w in [
7
urwid.Text("This is a text string that is fairly long"),
9
urwid.Text("Short one"),
10
urwid.Text("Another"),
12
urwid.Text("What could be after this?"),
13
urwid.Text("The end."),]])
14
listbox = urwid.ListBox(content)
15
show_key = urwid.Text("", wrap='clip')
16
head = urwid.AttrMap(show_key, 'header')
17
top = urwid.Frame(listbox, head)
19
def show_all_input(input, raw):
20
show_key.set_text("Pressed: " + " ".join([
21
unicode(i) for i in input]))
24
def exit_on_cr(input):
26
raise urwid.ExitMainLoop()
28
loop = urwid.MainLoop(top, palette,
29
input_filter=show_all_input, unhandled_input=exit_on_cr)