Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import maya.cmds
- import maya.mel
- class BaseGUI(object):
- @classmethod
- def showUI(cls):
- win=cls()
- win.createUI()
- def __init__(self):
- self.winName='window_Name'
- self.title='window title'
- self.size=(300,400)
- self.v=maya.mel.eval('getApplicationVersionAsFloat')
- if self.v>= 2011: self.dock=True
- else: self.dock=False
- def createUI(self):
- """
- Creates dockable GUI if maya version above 2011
- else creates flying window
- """
- if self.dock:
- if maya.cmds.dockControl(self.winName+"_dock",q=True,exists=True):
- maya.cmds.deleteUI(self.winName+"_dock")
- else:
- if maya.cmds.window(self.winName,q=True, exists=True):
- maya.cmds.deleteUI(self.winName)
- self.window=maya.cmds.window(self.winName, title = self.title,
- widthHeight=self.size,retain=False)
- self.tabLayout=maya.cmds.tabLayout('tabLayout',parent=self.winName,
- innerMarginWidth=5,scr=True,
- innerMarginHeight=5,cr=True)
- ###All controls to be placed in mainLayout###
- self.commonLayout()
- #Edit tabs layout
- self.editTabLayout()
- #Show the window
- if self.dock:
- maya.cmds.dockControl(self.winName+"_dock",w=self.size[0], label=self.title, area="left",
- content=self.winName)
- else:
- maya.cmds.showWindow(self.winName)
- def commonLayout(self):
- """ Add control in this method for by overriding in your py module"""
- self.mainLayout=maya.cmds.columnLayout("mainLayout",parent="tabLayout",adj=True)
- ## add more laytouts update editTabLayout accordingly..
- self.secondTab=maya.cmds.columnLayout('secondTab', adjustableColumn=True,parent="tabLayout")
- def editTabLayout(self):
- """You can add more tabs here, in tablayout by overriding this method in your py module"""
- maya.cmds.tabLayout( 'tabLayout', edit=True,scr=True,
- tabLabel=((self.mainLayout,'Label 1'),
- (self.secondTab, 'Label 2')
- )
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement