Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Urwid Problem
#!/usr/bin/env python3
import urwid
palette = [
('highlight', '', '', '', 'bold,#ff0', ''),
('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', '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)
listbox.set_focus(0)
loop.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.