def _check_save(self): if self.script_validator.errors: n = len(self.script_validator.errors) is_are = 'is' if n == 1 else 'are' e_es = 'error' if n == 1 else 'errors' d = confirmation(None, '''There {} {} {}. Are you sure you want to save ?'''.format(is_are, n, e_es)) r = d == 5103 else: r = True return r
def _key_changed(self, event): """ Handles a keyboard event. """ binding = self.object key_name = key_event_to_name(event) cur_binding = binding.owner.key_binding_for(binding, key_name) if cur_binding is not None: if confirmation( None, "'%s' has already been assigned to '%s'.\n" "Do you wish to continue?" % (key_name, cur_binding.description), 'Duplicate Key Definition') == 5104: return self.value = key_name
def _key_changed ( self, event ): """ Handles a keyboard event. """ binding = self.object key_name = key_event_to_name( event ) cur_binding = binding.owner.key_binding_for( binding, key_name ) if cur_binding is not None: if confirmation( None, "'%s' has already been assigned to '%s'.\n" "Do you wish to continue?" % ( key_name, cur_binding.description ), 'Duplicate Key Definition' ) == 5104: return self.value = key_name
def select_left_down(self, event): ''' ''' # item = self.valves[self.active_item] item = self.active_item if item is None: return if item.soft_lock: return state = item.state if isinstance(item, RoughValve) and not state: event.handled = True result = confirmation(None, 'Are you sure you want to open {}'.format(item.name)) if result == 5104: return state = not state ok = False if self.manager is not None: if state: # if self.manager.open_valve(item.name, mode = 'manual'): if self.manager.open_valve(item.name, mode='normal'): ok = True else: # if self.manager.close_valve(item.name, mode = 'manual'): if self.manager.close_valve(item.name, mode='normal'): ok = True else: ok = True # ok = True if ok and not item.soft_lock: item.state = state self.invalidate_and_redraw()