Skip to content

Instantly share code, notes, and snippets.

@geier
Created May 3, 2016 15:41
Show Gist options
  • Save geier/ee354d77e70f6955bc7ad3ac0bfb976b to your computer and use it in GitHub Desktop.
Save geier/ee354d77e70f6955bc7ad3ac0bfb976b to your computer and use it in GitHub Desktop.
minimal urwid example (ListWalker)
import urwid
class SelectableText(urwid.Text):
def selectable(self):
return True
def keypress(self, size, key):
return key
content = urwid.SimpleListWalker([
urwid.AttrMap(SelectableText('foo'), '', 'reveal focus'),
urwid.AttrMap(SelectableText('bar'), '', 'reveal focus'),
urwid.AttrMap(SelectableText('baz'), '', 'reveal focus'),
])
listbox = urwid.ListBox(content)
wrapped = listbox
palette = [
('reveal focus', 'black', 'dark cyan', 'standout')
]
loop = urwid.MainLoop(wrapped, palette=palette)
loop.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment