def setPrpty(self, sProperty, value, write=True): logMsg(self.__class__.__name__, log='all') metaprpty = self.__metaProperties[sProperty] if metaprpty.isValidValue(value): if write: if metaprpty.isWritable(): bStatus = metaprpty.write(value) if not bStatus: return False else: logMsg(u"<{}> Writing to non-writable property: {}.{} .". format(getCaller(), self, metaprpty.name), warning=True) setattr(self, metaprpty.name, value) return True else: logMsg(" {0}.{1} : Invalid value : '{2}'".format( self, sProperty, value), warning=True) return False
def onSelectionChanged(self, selected, deselected): caller = getCaller() #print "onSelectionChanged", caller if (caller is None) or (caller == "mousePressEvent"): self.itemPressed = True
def _writeAllValues(self, propertyNames=None): logMsg(self.__class__.__name__, log='all') sPropertyIter = self.__class__._iterPropertyArg(propertyNames) for sProperty in sPropertyIter: value = getattr(self, sProperty) bWriteOnly = False sSetFnc = "set" + upperFirst(sProperty) setFnc = getattr(self, sSetFnc, None) msg = u"Setting {0}.{1} to {2}( {3} ) using {4}".format( self, sProperty, type(value).__name__, toStr(value), setFnc if setFnc else "setPrpty") logMsg(msg, log="debug") bSuccess = False if setFnc: try: bSuccess = setFnc(value, writingAttrs=True) except TypeError: try: bSuccess = setFnc(value) except Exception, msg: logMsg(msg, warning=True) bWriteOnly = True else: bWriteOnly = True if bWriteOnly: metaprpty = self.__metaProperties[sProperty] if metaprpty.isWritable(): bSuccess = metaprpty.write(value) else: logMsg(u"<{}> Writing to non-writable property: {}.{} .". format(getCaller(), self, metaprpty.name), warning=True) bSuccess = True if not bSuccess: logMsg("Failed " + lowerFirst(msg), warning=True)
def _writeAllValues(self, propertyNames=None): logMsg(self.__class__.__name__, log='all') sPropertyIter = self.__class__._iterPropertyArg(propertyNames) for sProperty in sPropertyIter: value = getattr(self, sProperty) bWriteOnly = False sSetFnc = "set" + upperFirst(sProperty) setFnc = getattr(self, sSetFnc, None) msg = u"Setting {0}.{1} to {2}( {3} ) using {4}".format( self, sProperty, type(value).__name__, toStr(value), setFnc if setFnc else "setPrpty") logMsg(msg, log="debug") bSuccess = False if setFnc: try: bSuccess = setFnc(value, writingAttrs=True) except TypeError: try: bSuccess = setFnc(value) except Exception, msg: logMsg(msg , warning=True) bWriteOnly = True else: bWriteOnly = True if bWriteOnly: metaprpty = self.__metaProperties[sProperty] if metaprpty.isWritable(): bSuccess = metaprpty.write(value) else: logMsg(u"<{}> Writing to non-writable property: {}.{} ." .format(getCaller(), self, metaprpty.name), warning=True) bSuccess = True if not bSuccess: logMsg("Failed " + lowerFirst(msg), warning=True)
def setPrpty(self, sProperty, value, write=True): logMsg(self.__class__.__name__, log='all') metaprpty = self.__metaProperties[sProperty] if metaprpty.isValidValue(value): if write: if metaprpty.isWritable(): bStatus = metaprpty.write(value) if not bStatus: return False else: logMsg(u"<{}> Writing to non-writable property: {}.{} ." .format(getCaller(), self, metaprpty.name), warning=True) setattr(self, metaprpty.name, value) return True else: logMsg(" {0}.{1} : Invalid value : '{2}'" .format(self, sProperty, value) , warning=True) return False