Created
June 12, 2017 17:12
-
-
Save geier/4313dd83cb6bb04b98b8c5c2db8ebc6f to your computer and use it in GitHub Desktop.
This file contains 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
import random | |
import string | |
import urwid | |
def genaret_random_text(): | |
choice = string.ascii_uppercase + string.digits | |
return ''.join([random.choice(choice) for _ in range(36)]) | |
class SelectableText(urwid.Text): | |
def selectable(self): | |
return True | |
def keypress(self, size, key): | |
return key | |
list_content = list() | |
for _ in range(100): | |
list_content.append( | |
urwid.AttrMap(SelectableText(genaret_random_text()), 'foo', 'reveal focus'), | |
) | |
content = urwid.SimpleListWalker(list_content) | |
listbox = urwid.ListBox(content) | |
wrapped = listbox | |
palette = [ | |
('foo', 'dark red,italics', '', ''), | |
('reveal focus', 'black,blink', '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