Massage in ConfigParser
This commit is contained in:
@@ -1,25 +1,30 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# vim: tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
|
||||||
|
|
||||||
import urwid
|
import urwid
|
||||||
import urwid.raw_display
|
import ConfigParser
|
||||||
import urwid.web_display
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
text_header = (u"Welcome to the urwid tour! "
|
config = ConfigParser.SafeConfigParser()
|
||||||
u"UP / DOWN / PAGE UP / PAGE DOWN scroll. F8 exits.")
|
config.read("my_config_parser.ini")
|
||||||
text_button_list = [u"Yes", u"No", u"Perhaps", u"Certainly", u"Partially",
|
text_header = (u"SICS Config Editor!\n"
|
||||||
u"Tuesdays Only", u"Help"]
|
u"UP / DOWN / PAGE UP / PAGE DOWN scroll. F8 exits.")
|
||||||
text_cb_list = [u"Wax", u"Wash", u"Buff", u"Clear Coat", u"Dry",
|
text_button_list = [u"Yes", u"No", u"Perhaps", u"Certainly", u"Partially",
|
||||||
u"Racing Stripe"]
|
u"Tuesdays Only", u"Help"]
|
||||||
text_rb_list = [u"Morning", u"Afternoon", u"Evening", u"Weekend"]
|
text_cb_list = [u"Wax", u"Wash", u"Buff", u"Clear Coat", u"Dry",
|
||||||
|
u"Racing Stripe"]
|
||||||
|
text_cb_list = list(config.sections())
|
||||||
|
text_rb_list = [u"Morning", u"Afternoon", u"Evening", u"Weekend"]
|
||||||
|
|
||||||
|
|
||||||
def button_press(button):
|
def button_press(button):
|
||||||
frame.footer = urwid.AttrWrap(urwid.Text(
|
frame.footer = urwid.AttrWrap(urwid.Text(
|
||||||
[u"Pressed: ", button.get_label()]), 'header')
|
[u"Pressed: ", button.get_label()]), 'header')
|
||||||
|
|
||||||
radio_button_group = []
|
radio_button_group = []
|
||||||
|
|
||||||
blank = urwid.Divider()
|
blank = urwid.Divider()
|
||||||
listbox_content = [
|
listbox_content = [
|
||||||
urwid.Padding(urwid.GridFlow(
|
urwid.Padding(urwid.GridFlow(
|
||||||
[urwid.AttrWrap(urwid.Button(txt, button_press),
|
[urwid.AttrWrap(urwid.Button(txt, button_press),
|
||||||
'buttn','buttnf') for txt in text_button_list],
|
'buttn','buttnf') for txt in text_button_list],
|
||||||
@@ -40,11 +45,11 @@ def main():
|
|||||||
left=4, right=3, min_width=13),
|
left=4, right=3, min_width=13),
|
||||||
blank,
|
blank,
|
||||||
]
|
]
|
||||||
header = urwid.AttrWrap(urwid.Text(text_header), 'header')
|
header = urwid.AttrWrap(urwid.Text(text_header), 'header')
|
||||||
listbox = urwid.ListBox(urwid.SimpleListWalker(listbox_content))
|
listbox = urwid.ListBox(urwid.SimpleListWalker(listbox_content))
|
||||||
frame = urwid.Frame(urwid.AttrWrap(listbox, 'body'), header=header)
|
frame = urwid.Frame(urwid.AttrWrap(listbox, 'body'), header=header)
|
||||||
|
|
||||||
palette = [
|
palette = [
|
||||||
('body','black','light gray', 'standout'),
|
('body','black','light gray', 'standout'),
|
||||||
('reverse','light gray','black'),
|
('reverse','light gray','black'),
|
||||||
('header','white','dark red', 'bold'),
|
('header','white','dark red', 'bold'),
|
||||||
@@ -57,26 +62,15 @@ def main():
|
|||||||
('buttnf','white','dark blue','bold'),
|
('buttnf','white','dark blue','bold'),
|
||||||
]
|
]
|
||||||
|
|
||||||
if urwid.web_display.is_web_request():
|
def unhandled(key):
|
||||||
screen = urwid.web_display.Screen()
|
if key in ['q', 'Q', 'f8']:
|
||||||
else:
|
raise urwid.ExitMainLoop()
|
||||||
screen = urwid.raw_display.Screen()
|
|
||||||
|
|
||||||
def unhandled(key):
|
urwid.MainLoop(frame, palette, unhandled_input=unhandled).run()
|
||||||
if key == 'f8':
|
|
||||||
raise urwid.ExitMainLoop()
|
|
||||||
|
|
||||||
urwid.MainLoop(frame, palette, screen,
|
|
||||||
unhandled_input=unhandled).run()
|
|
||||||
|
|
||||||
def setup():
|
def setup():
|
||||||
urwid.web_display.set_preferences("Urwid Tour")
|
main()
|
||||||
# try to handle short web requests quickly
|
|
||||||
if urwid.web_display.handle_short_request():
|
|
||||||
return
|
|
||||||
|
|
||||||
main()
|
if '__main__'==__name__:
|
||||||
|
setup()
|
||||||
if '__main__'==__name__ or urwid.web_display.is_web_request():
|
|
||||||
setup()
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user