Replace deprecated urwid AttrWrap() with AttrMap()
This commit is contained in:
@@ -79,13 +79,13 @@ def main(config_filename):
|
|||||||
global config, verbose, depth_list, line_list
|
global config, verbose, depth_list, line_list
|
||||||
if len(depth_list) == 0:
|
if len(depth_list) == 0:
|
||||||
line_list = []
|
line_list = []
|
||||||
frame.footer = urwid.AttrWrap(urwid.Text(""), 'header')
|
frame.footer = urwid.AttrMap(urwid.Text(""), 'header')
|
||||||
config.set(user_data, 'enabled', str(new_state))
|
config.set(user_data, 'enabled', str(new_state))
|
||||||
if verbose:
|
if verbose:
|
||||||
line = u"Checkbox: name=%s, new_state=%s, user_data=%s" % (
|
line = u"Checkbox: name=%s, new_state=%s, user_data=%s" % (
|
||||||
check_box.get_label(), str(new_state), str(user_data))
|
check_box.get_label(), str(new_state), str(user_data))
|
||||||
line_list.append(line + "\n")
|
line_list.append(line + "\n")
|
||||||
frame.footer = urwid.AttrWrap(urwid.Text(line_list), 'header')
|
frame.footer = urwid.AttrMap(urwid.Text(line_list), 'header')
|
||||||
try:
|
try:
|
||||||
order = ['offifoff', 'offifon', 'onifon', 'onifoff', 'cascade']
|
order = ['offifoff', 'offifon', 'onifon', 'onifoff', 'cascade']
|
||||||
if 'order' in config.options(user_data):
|
if 'order' in config.options(user_data):
|
||||||
@@ -104,7 +104,7 @@ def main(config_filename):
|
|||||||
except Exception as prang:
|
except Exception as prang:
|
||||||
line = "Exception: %s" % prang
|
line = "Exception: %s" % prang
|
||||||
line_list.append(line + "\n")
|
line_list.append(line + "\n")
|
||||||
frame.footer = urwid.AttrWrap(urwid.Text(line_list), 'header')
|
frame.footer = urwid.AttrMap(urwid.Text(line_list), 'header')
|
||||||
|
|
||||||
text_cb_list = list(config.sections())
|
text_cb_list = list(config.sections())
|
||||||
cb_map = {}
|
cb_map = {}
|
||||||
@@ -120,7 +120,7 @@ def main(config_filename):
|
|||||||
cb_list = []
|
cb_list = []
|
||||||
for key in sorted(cb_map.keys()):
|
for key in sorted(cb_map.keys()):
|
||||||
if len(key) > 0:
|
if len(key) > 0:
|
||||||
lb_list.append(urwid.AttrWrap(urwid.Text("Group: %s" % key), 'bright'))
|
lb_list.append(urwid.AttrMap(urwid.Text("Group: %s" % key), 'bright'))
|
||||||
for txt in sorted(cb_map[key]):
|
for txt in sorted(cb_map[key]):
|
||||||
state = False
|
state = False
|
||||||
if 'enabled' in config.options(txt):
|
if 'enabled' in config.options(txt):
|
||||||
@@ -139,14 +139,14 @@ def main(config_filename):
|
|||||||
radio = config.get(txt, 'radio').strip("\"")
|
radio = config.get(txt, 'radio').strip("\"")
|
||||||
if radio not in Radio_Groups:
|
if radio not in Radio_Groups:
|
||||||
Radio_Groups[radio] = []
|
Radio_Groups[radio] = []
|
||||||
cb = urwid.AttrWrap(urwid.RadioButton(
|
cb = urwid.AttrMap(urwid.RadioButton(
|
||||||
Radio_Groups[radio],
|
Radio_Groups[radio],
|
||||||
cb_text,
|
cb_text,
|
||||||
state=state,
|
state=state,
|
||||||
on_state_change=checkbox_change,
|
on_state_change=checkbox_change,
|
||||||
user_data=txt), 'buttn', 'buttnf')
|
user_data=txt), 'buttn', 'buttnf')
|
||||||
else:
|
else:
|
||||||
cb = urwid.AttrWrap(urwid.CheckBox(cb_text,
|
cb = urwid.AttrMap(urwid.CheckBox(cb_text,
|
||||||
state=state,
|
state=state,
|
||||||
on_state_change=checkbox_change,
|
on_state_change=checkbox_change,
|
||||||
user_data=txt), 'buttn', 'buttnf')
|
user_data=txt), 'buttn', 'buttnf')
|
||||||
@@ -154,7 +154,7 @@ def main(config_filename):
|
|||||||
lb_list.append(cb)
|
lb_list.append(cb)
|
||||||
|
|
||||||
def fcc(focus):
|
def fcc(focus):
|
||||||
frame.footer = urwid.AttrWrap(urwid.Text(
|
frame.footer = urwid.AttrMap(urwid.Text(
|
||||||
[u"Focus: " + str(focus)]), 'header')
|
[u"Focus: " + str(focus)]), 'header')
|
||||||
|
|
||||||
|
|
||||||
@@ -170,11 +170,11 @@ def main(config_filename):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
header = urwid.AttrWrap(urwid.Text(text_header), 'header')
|
header = urwid.AttrMap(urwid.Text(text_header), 'header')
|
||||||
sflw = urwid.SimpleListWalker(lb_list)
|
sflw = urwid.SimpleListWalker(lb_list)
|
||||||
listbox = urwid.ListBox(sflw)
|
listbox = urwid.ListBox(sflw)
|
||||||
frame = urwid.Frame(urwid.AttrWrap(listbox, 'body'), header=header)
|
frame = urwid.Frame(urwid.AttrMap(listbox, 'body'), header=header)
|
||||||
frame.footer = urwid.AttrWrap(urwid.Text(""), 'header')
|
frame.footer = urwid.AttrMap(urwid.Text(""), 'header')
|
||||||
|
|
||||||
palette = [
|
palette = [
|
||||||
('body', 'black', 'light gray', 'standout'),
|
('body', 'black', 'light gray', 'standout'),
|
||||||
@@ -198,19 +198,19 @@ def main(config_filename):
|
|||||||
config = reread_config_file(config_filename, cb_list)
|
config = reread_config_file(config_filename, cb_list)
|
||||||
elif key in ['e', 'E', 'f4']:
|
elif key in ['e', 'E', 'f4']:
|
||||||
f = sflw.get_focus()
|
f = sflw.get_focus()
|
||||||
frame.footer = urwid.AttrWrap(urwid.Text([u"EditE: " + str(dir(f[0]))]), 'header')
|
frame.footer = urwid.AttrMap(urwid.Text([u"EditE: " + str(dir(f[0]))]), 'header')
|
||||||
elif key in ['q', 'Q', 'f8']:
|
elif key in ['q', 'Q', 'f8']:
|
||||||
raise urwid.ExitMainLoop()
|
raise urwid.ExitMainLoop()
|
||||||
# elif key in ['b', 'B']:
|
# elif key in ['b', 'B']:
|
||||||
# l = sflw[1].base_widget
|
# l = sflw[1].base_widget
|
||||||
# f = l.focus_cell
|
# f = l.focus_cell
|
||||||
# b = l.cells.index(f)
|
# b = l.cells.index(f)
|
||||||
# l.cells.insert(b + 1, urwid.AttrWrap(urwid.Edit(edit_text=u"Hello"), 'header'))
|
# l.cells.insert(b + 1, urwid.AttrMap(urwid.Edit(edit_text=u"Hello"), 'header'))
|
||||||
# l.set_focus(b + 1)
|
# l.set_focus(b + 1)
|
||||||
# frame.footer = urwid.AttrWrap(urwid.Text([u"EditB: " + str(b)]), 'header')
|
# frame.footer = urwid.AttrMap(urwid.Text([u"EditB: " + str(b)]), 'header')
|
||||||
else:
|
else:
|
||||||
if not key[0] == 'mouse release':
|
if not key[0] == 'mouse release':
|
||||||
frame.footer = urwid.AttrWrap(urwid.Text([u"Press: " + str(key)]), 'header')
|
frame.footer = urwid.AttrMap(urwid.Text([u"Press: " + str(key)]), 'header')
|
||||||
|
|
||||||
urwid.MainLoop(frame, palette, unhandled_input=unhandled).run()
|
urwid.MainLoop(frame, palette, unhandled_input=unhandled).run()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user