7.2 基本GUI命令
在GUI元素名称前添加其姓名或工作室的首字母作为前缀。
import maya.cmds as cmds
cmds.deleteUI(win,window = True)
win = cmds.window(
'ar_optionsWindow',
title = 'My First Window',
widthHeight = (546,350)
)
cmds.showWindow(win)
7.3 构建窗基类
class AR_OptionsWindow(object):
def __init__(self):
self.window = 'ar_optionWindow'
self.title = 'Options Window'
self.size = (546,350)
def create(self):
if cmds.window(self.window,exists = True):
cmds.deleteUI(self.window,window = True)
self.window = cmds.window(
self.window,
title = self.title,
widthHeight = self.size
)
cmds.showWindow()
testWindow = AR_OptionsWindow()
testWindow.create()
class AR_OptionsWindow(object):
def __init__(self):
self.window = 'ar_optionWindow'
self.title = 'Options Window'
self.size = (546,350)
def commonMenu(self):
self.editMenu = cmds.menu(label = 'Edit')
self.editMenuSave = cmds.menuItem(
label = 'Save Settings'
)
self.editMenuReset = cmds.menuItem(
label = 'Restet Settings'
)
self.editMenuDiv = cmds.menuItem(d = True)
self.editMenuRadio = cmds.radioMenuItemCollection()
self.editMenuTool = cmds.menuItem(
label = 'As Tool',
radioButton = True,
#enable = self.supportsToolAction
)
self.editMenuTool = cmds.menuItem(
label = 'As Action',
radioButton = True,
# enable = self.supportsToolAction
)
self.helpMenu = cmds.menu(label = 'Help')
self.helpMenuItem = cmds.menuItem(
label = 'Help on %s'%self.title
)
def create(self):
if cmds.window(self.window,exists = True):
cmds.deleteUI(self.window,window= True)
self.window = cmds.window(
self.window,
title = self.title,
widthHeight = self.size,
menuBar = True
)
self.commonMenu()
cmds.showWindow()
testWindow = AR_OptionsWindow()
testWindow.create()
对GUI对象执行命令
使用functools模块