Created
January 11, 2019 14:02
-
-
Save Arax20/8e8d94e1c602424c281b40a6697f8aff to your computer and use it in GitHub Desktop.
[UrWid Testing] #urwid #cli
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 urwid | |
#---Header--- | |
header_text = urwid.Text(u' Periodic Table') | |
header = urwid.AttrMap(header_text, 'titlebar') | |
#---Periodic Table--- | |
periodictable_text = urwid.Text(u'A periodic table should be here') | |
periodictable_filler = urwid.Filler(periodictable_text, valign='top', top=1, bottom=1) | |
v_padding = urwid.Padding(periodictable_filler, left=1, right=1) | |
periodictable = urwid.LineBox(v_padding) | |
#---Info--- | |
info = urwid.Text(u'There will be some info on elements here') | |
#---Palette--- | |
palette = [ | |
('titlebar', 'dark red', ''), | |
('quit button', 'dark red', ''), | |
('headers', 'white,bold', '') | |
] | |
#---Handle Input--- | |
def handle_input(key): | |
if key == ':': | |
info = urwid.Text(u'Oooga Booooga') | |
refresh(main_loop, '') | |
if key == 'q': | |
raise urwid.ExitMainLoop() | |
layout = urwid.Frame(header=header, body=periodictable, footer=info) | |
main_loop = urwid.MainLoop(layout, palette, unhandled_input=handle_input) | |
main_loop.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment