コード例 #1
0
ファイル: ctrl_maya.py プロジェクト: Italic-/maya-prefs
def getController(uiType, control, defaultValue):
    if uiType in constructors:
        pmUiType = constructors[uiType][IDX_PM_TYPE]
        pmClass = constructors[uiType][IDX_PM_CLASS]
        return pmGetController(pmUiType, pmClass(control), defaultValue)
    else:
        message('Cannot create controller: Unknown controller type: {0}.'.format(str(uiType)))
コード例 #2
0
def getController(uiType, control, defaultValue):

    if uiType in constructors:
        return constructors[uiType](control, defaultValue)
    else:
        message(
            'Cannot create controller: Unknown controller type: {0}.'.format(
                str(uiType)))
コード例 #3
0
ファイル: serializers.py プロジェクト: Italic-/maya-prefs
 def load(self):
     if not m.optionVar(exists=self.optVarName):
         return {}
     try:
         obj = json.loads(m.optionVar(q=self.optVarName))
     except Exception as e:
         message('Error occurred while loading option variable {0}.\nAdditional exception info:\n{1}'.format(self.optVarName, str(e)))
         raise
     return obj
コード例 #4
0
def getController(uiType, control, defaultValue):
    if uiType in constructors:
        pmUiType = constructors[uiType][IDX_PM_TYPE]
        pmClass = constructors[uiType][IDX_PM_CLASS]
        return pmGetController(pmUiType, pmClass(control), defaultValue)
    else:
        message(
            'Cannot create controller: Unknown controller type: {0}.'.format(
                str(uiType)))
コード例 #5
0
ファイル: serializers.py プロジェクト: jubeyjose/maya-prefs
 def load(self):
     if not m.optionVar(exists=self.optVarName):
         return {}
     try:
         obj = json.loads(m.optionVar(q=self.optVarName))
     except Exception as e:
         message(
             'Error occurred while loading option variable {0}.\nAdditional exception info:\n{1}'
             .format(self.optVarName, str(e)))
         raise
     return obj
コード例 #6
0
ファイル: serializers.py プロジェクト: jubeyjose/maya-prefs
 def save(self, obj):
     try:
         m.optionVar(stringValue=(
             self.optVarName,
             json.dumps(
                 obj, sort_keys=True, indent=4, separators=(',', ': '))))
     except Exception as e:
         message(
             'Error occurred while saving option variable {0}.\nAdditional exception info:\n{1}'
             .format(self.optVarName, str(e)))
         raise
コード例 #7
0
ファイル: serializers.py プロジェクト: Italic-/maya-prefs
 def save(self, obj):
     try:
         f = open(self.filename, 'wb')
         try:
             self.saveProcedure(obj, f)
         finally:
             f.close()
     except IOError as e:
         message('Error writing file. Filename: {0}.\nAdditional exception info:\n{1}'.format(self.filename, str(e)))
         raise
     except Exception as e:
         message('Error occurred during serialization. Filename: {0}.\nAdditional exception info:\n{1}'.format(self.filename, str(e)))
         raise
コード例 #8
0
ファイル: prefsaver.py プロジェクト: Italic-/maya-prefs
    def addControl(self, control, uiType, defaultValue=None):

        if not UIType.isTypeOf(uiType, UIType.TypesAll):
            message('Cannot add unknown control type ({0}) for {1}. Skipped'.format(uiType, str(control)))
            return

        if UIType.isTypeOf(uiType, UIType.TypesPYQT | UIType.TypesPYSIDE):
            controller = ctrl_qt.getController(uiType, control, defaultValue)
            if controller:
                self.controllers.append(controller)
            else:
                message('Failed to add controller (type={0}) for {1}'.format(uiType, str(control)))
            return

        if UIType.isTypeOf(uiType, UIType.TypesM):
            if ctrl_maya:
                self.controllers.append(ctrl_maya.getController(uiType, control, defaultValue))
            else:
                message('Failed to add controller (type={0}) for {1}'.format(uiType, str(control)))
            return

        if UIType.isTypeOf(uiType, UIType.TypesPM):
            if ctrl_pymel:
                self.controllers.append(ctrl_pymel.getController(uiType, control, defaultValue))
            else:
                message('Failed to add controller (type={0}) for {1}'.format(uiType, str(control)))
            return

        assert False, 'Failed to add a controller.'
コード例 #9
0
    def addControl(self, control, uiType, defaultValue=None):

        if not UIType.isTypeOf(uiType, UIType.TypesAll):
            message('Cannot add unknown control type ({0}) for {1}. Skipped'.
                    format(uiType, str(control)))
            return

        if UIType.isTypeOf(uiType, UIType.TypesPYQT | UIType.TypesPYSIDE):
            controller = ctrl_qt.getController(uiType, control, defaultValue)
            if controller:
                self.controllers.append(controller)
            else:
                message('Failed to add controller (type={0}) for {1}'.format(
                    uiType, str(control)))
            return

        if UIType.isTypeOf(uiType, UIType.TypesM):
            if ctrl_maya:
                self.controllers.append(
                    ctrl_maya.getController(uiType, control, defaultValue))
            else:
                message('Failed to add controller (type={0}) for {1}'.format(
                    uiType, str(control)))
            return

        if UIType.isTypeOf(uiType, UIType.TypesPM):
            if ctrl_pymel:
                self.controllers.append(
                    ctrl_pymel.getController(uiType, control, defaultValue))
            else:
                message('Failed to add controller (type={0}) for {1}'.format(
                    uiType, str(control)))
            return

        assert False, 'Failed to add a controller.'
コード例 #10
0
ファイル: ctrl_qt.py プロジェクト: youndoldman/fxpt
def getController(uiType, control, defaultValue):

    if uiType in constructors:

        if UIType.isTypeOf(uiType, UIType.TypesPYQT):
            if _PyQt4:
                return constructors[uiType](_PyQt4, control, defaultValue)
            else:
                message('Cannot create controller: PyQt is not available.')
                return

        if UIType.isTypeOf(uiType, UIType.TypesPYSIDE):
            if _PySide:
                return constructors[uiType](_PySide, control, defaultValue)
            else:
                message('Cannot create controller: PySide is not available.')
                return
コード例 #11
0
ファイル: ctrl_qt.py プロジェクト: theetcher/fxpt
def getController(uiType, control, defaultValue):

    if uiType in constructors:

        if UIType.isTypeOf(uiType, UIType.TypesPYQT):
            if _PyQt4:
                return constructors[uiType](_PyQt4, control, defaultValue)
            else:
                message('Cannot create controller: PyQt is not available.')
                return

        if UIType.isTypeOf(uiType, UIType.TypesPYSIDE):
            if _PySide:
                return constructors[uiType](_PySide, control, defaultValue)
            else:
                message('Cannot create controller: PySide is not available.')
                return
コード例 #12
0
ファイル: serializers.py プロジェクト: jubeyjose/maya-prefs
 def save(self, obj):
     try:
         f = open(self.filename, 'wb')
         try:
             self.saveProcedure(obj, f)
         finally:
             f.close()
     except IOError as e:
         message(
             'Error writing file. Filename: {0}.\nAdditional exception info:\n{1}'
             .format(self.filename, str(e)))
         raise
     except Exception as e:
         message(
             'Error occurred during serialization. Filename: {0}.\nAdditional exception info:\n{1}'
             .format(self.filename, str(e)))
         raise
コード例 #13
0
ファイル: serializers.py プロジェクト: Italic-/maya-prefs
    def load(self):
        if not os.path.exists(self.filename):
            return {}

        try:
            f = open(self.filename, 'rb')
            try:
                obj = self.loadProcedure(f)
            finally:
                f.close()
        except IOError as e:
            message('Error reading file. Filename: {0}.\nAdditional exception info:\n{1}'.format(self.filename, str(e)))
            raise
        except Exception as e:
            message('Error occurred during deserialization. Filename: {0}.\nAdditional exception info:\n{1}'.format(self.filename, str(e)))
            raise

        return obj
コード例 #14
0
ファイル: serializers.py プロジェクト: jubeyjose/maya-prefs
    def load(self):
        if not os.path.exists(self.filename):
            return {}

        try:
            f = open(self.filename, 'rb')
            try:
                obj = self.loadProcedure(f)
            finally:
                f.close()
        except IOError as e:
            message(
                'Error reading file. Filename: {0}.\nAdditional exception info:\n{1}'
                .format(self.filename, str(e)))
            raise
        except Exception as e:
            message(
                'Error occurred during deserialization. Filename: {0}.\nAdditional exception info:\n{1}'
                .format(self.filename, str(e)))
            raise

        return obj
コード例 #15
0
ファイル: serializers.py プロジェクト: Italic-/maya-prefs
 def save(self, obj):
     try:
         m.optionVar(stringValue=(self.optVarName, json.dumps(obj, sort_keys=True, indent=4, separators=(',', ': '))))
     except Exception as e:
         message('Error occurred while saving option variable {0}.\nAdditional exception info:\n{1}'.format(self.optVarName, str(e)))
         raise
コード例 #16
0
ファイル: ctrl_pymel.py プロジェクト: Italic-/maya-prefs
def getController(uiType, control, defaultValue):

    if uiType in constructors:
        return constructors[uiType](control, defaultValue)
    else:
        message('Cannot create controller: Unknown controller type: {0}.'.format(str(uiType)))