Cleanup and put focus change on cb_list
This commit is contained in:
@@ -10,8 +10,6 @@ def main():
|
||||
config.read("my_config_parser.ini")
|
||||
text_header = (u"SICS Config Editor!\n"
|
||||
u"UP / DOWN / PAGE UP / PAGE DOWN scroll. F8 exits.")
|
||||
text_button_list = [u"Yes", u"No", u"Perhaps", u"Certainly", u"Partially",
|
||||
u"Tuesdays Only", u"Help"]
|
||||
|
||||
def checkbox_change(check_box, new_state, user_data):
|
||||
config.set(user_data, 'enabled', str(new_state))
|
||||
@@ -21,6 +19,7 @@ def main():
|
||||
line), 'header')
|
||||
|
||||
text_cb_list = list(config.sections())
|
||||
print text_cb_list
|
||||
cb_list = []
|
||||
for txt in text_cb_list:
|
||||
state = False
|
||||
@@ -35,45 +34,17 @@ def main():
|
||||
user_data=txt),
|
||||
'buttn','buttnf')
|
||||
cb_list.append(cb)
|
||||
text_rb_list = [u"Morning", u"Afternoon", u"Evening", u"Weekend"]
|
||||
|
||||
|
||||
def button_press(button):
|
||||
frame.footer = urwid.AttrWrap(urwid.Text(
|
||||
[u"Pressed: ", button.get_label()]), 'header')
|
||||
print cb_list
|
||||
|
||||
def fcc(focus):
|
||||
frame.footer = urwid.AttrWrap(urwid.Text(
|
||||
[u"Focus: " + str(focus)]), 'header')
|
||||
|
||||
radio_button_group = []
|
||||
pile = urwid.Pile(cb_list)
|
||||
edit = urwid.Edit()
|
||||
cols = urwid.Columns([pile, edit])
|
||||
blank = urwid.Divider()
|
||||
listbox_content = [
|
||||
# urwid.Padding(urwid.GridFlow(
|
||||
# [urwid.AttrWrap(urwid.Button(txt, button_press),
|
||||
# 'buttn','buttnf') for txt in text_button_list],
|
||||
# 13, 3, 1, 'left'),
|
||||
# left=4, right=3, min_width=13),
|
||||
blank,
|
||||
urwid.Padding(cols,
|
||||
left=4, right=3, min_width=10),
|
||||
blank,
|
||||
# urwid.Padding(urwid.GridFlow(
|
||||
# [urwid.AttrWrap(urwid.RadioButton(radio_button_group,
|
||||
# txt), 'buttn','buttnf')
|
||||
# for txt in text_rb_list],
|
||||
# 13, 3, 1, 'left') ,
|
||||
# left=4, right=3, min_width=13),
|
||||
# blank,
|
||||
]
|
||||
header = urwid.AttrWrap(urwid.Text(text_header), 'header')
|
||||
# TODO: Make this operate on the cb_list
|
||||
sflw = urwid.SimpleFocusListWalker(listbox_content)
|
||||
sflw = urwid.SimpleFocusListWalker(cb_list)
|
||||
sflw.set_focus_changed_callback(fcc)
|
||||
listbox = urwid.ListBox(sflw)
|
||||
|
||||
header = urwid.AttrWrap(urwid.Text(text_header), 'header')
|
||||
frame = urwid.Frame(urwid.AttrWrap(listbox, 'body'), header=header)
|
||||
|
||||
palette = [
|
||||
@@ -93,8 +64,11 @@ def main():
|
||||
if key in ['w', 'W', 'f10']:
|
||||
with open("junk.ini", "wb") as configfile:
|
||||
config.write(configfile)
|
||||
if key in ['q', 'Q', 'f8']:
|
||||
elif key in ['q', 'Q', 'f8']:
|
||||
raise urwid.ExitMainLoop()
|
||||
else:
|
||||
frame.footer = urwid.AttrWrap(urwid.Text(
|
||||
[u"Press: " + str(key)]), 'header')
|
||||
|
||||
urwid.MainLoop(frame, palette, unhandled_input=unhandled).run()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user