本文整理汇总了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