From 39a7569b9c01dbc1dd6584b7520d937e19e5fdc6 Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Wed, 27 Jul 2011 19:20:05 -0600 Subject: [PATCH] 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. --- pudb/settings.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/pudb/settings.py b/pudb/settings.py index bee93e7..efadd9d 100644 --- a/pudb/settings.py +++ b/pudb/settings.py @@ -91,10 +91,19 @@ def edit_config(ui, conf_dict): old_conf_dict = conf_dict.copy() - def _update_config(check_box, new_state, new_conf_dict): - if new_state: + 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) - ui.setup_palette(ui.screen) 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),