当前位置: 首页>>代码示例>>Python>>正文


Python MGlobal.optionVarStringValue方法代码示例

本文整理汇总了Python中maya.OpenMaya.MGlobal.optionVarStringValue方法的典型用法代码示例。如果您正苦于以下问题:Python MGlobal.optionVarStringValue方法的具体用法?Python MGlobal.optionVarStringValue怎么用?Python MGlobal.optionVarStringValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在maya.OpenMaya.MGlobal的用法示例。


在下文中一共展示了MGlobal.optionVarStringValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _setupLevelPreferenceHook

# 需要导入模块: from maya.OpenMaya import MGlobal [as 别名]
# 或者: from maya.OpenMaya.MGlobal import optionVarStringValue [as 别名]
def _setupLevelPreferenceHook():
    """Sets up a callback so that the last used log-level is saved to the user preferences file"""

    LOGLEVEL_OPTVAR = 'pymel.logLevel'


    # retrieve the preference as a string name, for human readability.
    # we need to use MGlobal because cmds.optionVar might not exist yet
    # TODO : resolve load order for standalone.  i don't think that userPrefs is loaded yet at this point in standalone.
    levelName = os.environ.get( PYMEL_LOGLEVEL_ENV_VAR,
                                MGlobal.optionVarStringValue( LOGLEVEL_OPTVAR ) )
    if levelName:
        level =  min( logging.WARNING, nameToLevel(levelName) ) # no more than WARNING level
        pymelLogger.setLevel(level)
        pymelLogger.info("setting logLevel to user preference: %s (%d)" % (levelName, level) )

    func = pymelLogger.setLevel
    def setLevelHook(level, *args, **kwargs):

        levelName = levelToName(level)
        level = nameToLevel(level)
        ret = func(level, *args, **kwargs)
        pymelLogger.info("Log Level Changed to '%s'" % levelName)
        try:
            # save the preference as a string name, for human readability
            # we need to use MGlobal because cmds.optionVar might not exist yet
            MGlobal.setOptionVarValue( LOGLEVEL_OPTVAR, levelName )
        except Exception, e:
            pymelLogger.warning("Log Level could not be saved to the user-prefs ('%s')" % e)
        return ret
开发者ID:0xb1dd1e,项目名称:PipelineConstructionSet,代码行数:32,代码来源:plogging.py


注:本文中的maya.OpenMaya.MGlobal.optionVarStringValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。