Skip to content

Instantly share code, notes, and snippets.

@vindolin
Created January 6, 2016 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vindolin/cfb01e94302068f07389 to your computer and use it in GitHub Desktop.
Save vindolin/cfb01e94302068f07389 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import urwid
palette = [
('highlight', '', '', '', 'bold,#ff0', ''),
('highlight_focus', '', '', '', 'bold,#ff0', '#da0'),
('item_focus','', '', '', '', '#da0'),
]
class Item(urwid.WidgetWrap):
def __init__(self, number):
urwid.WidgetWrap.__init__(
self,
urwid.AttrMap(
urwid.Text([
str(number),
' before',
('highlight', 'xx'),
'after'
], align='left')
,'item', {'highlight': 'highlight_focus', None: 'item_focus'})
)
def selectable(self):
return True
def keypress(self, size, key):
return key
listbox = urwid.ListBox(
urwid.SimpleListWalker(
[Item(i) for i in range(10)]
)
)
loop = urwid.MainLoop(listbox, palette)
loop.screen.set_terminal_properties(colors=256)
loop.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment