From 46b0e1a9a30bfe37d5b6a2012bdecd6193e0dc8e Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Sun, 6 Jul 2014 20:09:15 +1000 Subject: [PATCH] Provide navigation context for __imp_unavailable method. --- site_ansto/instrument/util/config_edit.py | 25 ++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/site_ansto/instrument/util/config_edit.py b/site_ansto/instrument/util/config_edit.py index 44402e82..f7b1c92e 100755 --- a/site_ansto/instrument/util/config_edit.py +++ b/site_ansto/instrument/util/config_edit.py @@ -445,7 +445,7 @@ class InstConfigManager(object): self.opt_lb.set_focus(0) return - def __imp_unavailable(self, opt, imp): + def __imp_unavailable(self, opt, imp, action): """Return True if an implementation is unavailable because it is used by an enabled option. """ @@ -457,10 +457,18 @@ class InstConfigManager(object): return False opt_imp = self.cf_dat.opt_dict[opt]['selected_imp'] - if opt_imp == imp: - return False - elif self.cf_dat.opt_dict[ckopt]['enabled']: - return True + if (action == 'focus'): + if opt_imp == imp: + return False + elif self.cf_dat.opt_dict[ckopt]['enabled']: + return True + else: + return False + elif (action == 'state_change'): + if self.cf_dat.opt_dict[ckopt]['enabled']: + return True + else: + return False else: return False @@ -468,7 +476,7 @@ class InstConfigManager(object): """Generate the appropriate listwalker for the given option.""" imp_items = [] for imp in self.cf_dat.iter_implementations(opt): - if self.__imp_unavailable(opt, imp): + if self.__imp_unavailable(opt, imp, 'focus'): continue if imp == self.cf_dat.opt_dict[opt]['selected_imp']: imp_items.append((imp, True)) @@ -514,12 +522,14 @@ class InstConfigManager(object): opt = button.get_label().split(':')[0] imp = self.cf_dat.opt_dict[opt]['selected_imp'] if new_state == True: - if self.__imp_unavailable(opt, imp): + if self.__imp_unavailable(opt, imp, 'state_change'): self.cf_dat.opt_dict[opt]['selected_imp'] = 'none' imp_none_button = self.imp_lw.button_dict['none'] imp_none_button.set_state(True) opt_button = self.opt_lw.button_dict[opt] opt_button.set_label('{0}:none'.format(opt)) + self.imp_lw = self.__gen_imp_listwalker(opt) + self.imp_lb.use_listwalker(self.imp_lw) else: opt_button = self.opt_lw.button_dict[opt] opt_button.set_label('{0}:{1}'.format(opt, imp)) @@ -605,6 +615,7 @@ class DEBUG: DBG = DEBUG(enabled=True) def main(config_ini): + global cf_dat, cf_man, cf_viewer """Create configuration editor.""" # Make configuration data