def __get__(self, instance, type=None): # Under certain circumstances, PyQt will try and access these properties # while loading the ui file, so we have to be robust to failures. # However, we print out a warning if things fail. try: widget = reduce(getattr, [instance] + self._att) return self.getter(widget) except Exception: logger.info("An error occured when accessing attribute {0} of {1}. Returning None.".format('.'.join(self._att), instance)) return None
def __set__(self, instance, value): widget = reduce(getattr, [instance] + self._att) self.setter(widget, value)
def __set__(self, instance, value): v = self.key.split('.') attr = reduce(getattr, [instance] + v[:-1]) setattr(attr, v[-1], value)
def __get__(self, instance, type=None): widget = reduce(getattr, [instance] + self._att) return self.getter(widget)