Fix the line number setting auto-updating

The problem was that the change didn't propagate to the global dict as I
thought it would.  So instead, we use the get_state() of the checkbox
(which is backwards by the way).  ui.setup_palette() doesn't seem to be
necessary in this case, so I left it out.  Anyway, it will still be
called when the dialog is closed.
This commit is contained in:
Aaron Meurer 2011-07-27 19:20:05 -06:00
parent 2433a8be34
commit 39a7569b9c

View File

@ -91,11 +91,20 @@ def edit_config(ui, conf_dict):
old_conf_dict = conf_dict.copy()
def _update_config(check_box, new_state, new_conf_dict):
def _update_config(check_box, new_state, option_newvalue):
option, newvalue = option_newvalue
new_conf_dict = {option: newvalue}
if option == "theme":
if new_state:
conf_dict.update(new_conf_dict)
ui.setup_palette(ui.screen)
for sl in ui.source:
sl._invalidate()
elif option == "line_numbers":
new_conf_dict["line_numbers"] = not check_box.get_state()
conf_dict.update(new_conf_dict)
for sl in ui.source:
sl._invalidate()
@ -106,7 +115,7 @@ def edit_config(ui, conf_dict):
cb_line_numbers = urwid.CheckBox("Show Line Numbers",
bool(conf_dict["line_numbers"]), on_state_change=_update_config,
user_data={"line_numbers": not conf_dict["line_numbers"]})
user_data=("line_numbers", None))
shell_info = urwid.Text("This is the shell that will be used when you hit !\n")
shells = ["classic", "ipython"]
@ -126,11 +135,11 @@ def edit_config(ui, conf_dict):
theme_rbs = [
urwid.RadioButton(theme_rb_grp, name,
conf_dict["theme"] == name, on_state_change=_update_config,
user_data={"theme": name})
user_data=("theme", name))
for name in THEMES]+[
urwid.RadioButton(theme_rb_grp, "Custom:",
not known_theme, on_state_change=_update_config,
user_data={"theme": name}),
user_data=("theme", name)),
urwid.Padding(
urwid.AttrMap(theme_edit, "value"),
left=4),