import maya.cmds as mc class BaseWindow(object): WINDOW_NAME = 'BaseWindow' WINDOW_TITLE = 'Base Window by PlanetaCG' WIDTH = 300 HEIGHT = 600 SCROLLABLE = True def __init__(self, dock=False, allowedAreas=('right', 'left')): """ """ self.allowedAreas = allowedAreas self.dockable = dock self.CreateUI() def CreateUI(self): """ """ if mc.window(self.WINDOW_NAME, exists=True): mc.deleteUI(self.WINDOW_NAME) # Window self.window = mc.window(self.WINDOW_NAME, title=self.WINDOW_TITLE, width=self.WIDTH, height=self.HEIGHT, sizeable=True, minimizeButton=False, maximizeButton=False) mc.window(self.window, edit=True, width=self.WIDTH, height=self.HEIGHT) self.mainLayout = mc.columnLayout('mainLayout', width=self.WIDTH) self.contentLayout = self.mainLayout if self.SCROLLABLE: self.scrollLayout = mc.scrollLayout('scrollLayout', width=self.WIDTH, height=self.HEIGHT, parent=self.mainLayout) self.contentLayout = mc.columnLayout('contentLayout', width=self.WIDTH - 16, parent=self.scrollLayout) self.CreateCustomUI() if self.dockable: mc.dockControl(label=self.WINDOW_TITLE, area='right', content=self.window, allowedArea=self.allowedAreas) # mc.showWindow(self.window) def CreateCustomUI(self): """ """ print 'BaseWindow.CreateCustomUI Override this function in child classes' window = BaseWindow(dock=True)