Created
January 6, 2016 17:17
-
-
Save vindolin/cfb01e94302068f07389 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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