Advertisement
gmendieta

Maya dock window with cmds

Mar 7th, 2018
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.57 KB | None | 0 0
  1. import maya.cmds as mc
  2.  
  3. class BaseWindow(object):
  4.  
  5.     WINDOW_NAME = 'BaseWindow'
  6.     WINDOW_TITLE = 'Base Window by PlanetaCG'
  7.     WIDTH = 300
  8.     HEIGHT = 600
  9.     SCROLLABLE = True
  10.  
  11.     def __init__(self, dock=False, allowedAreas=('right', 'left')):
  12.         """ """
  13.         self.allowedAreas = allowedAreas
  14.         self.dockable = dock
  15.         self.CreateUI()
  16.  
  17.     def CreateUI(self):
  18.         """ """
  19.         if mc.window(self.WINDOW_NAME, exists=True):
  20.             mc.deleteUI(self.WINDOW_NAME)
  21.  
  22.         # Window
  23.         self.window = mc.window(self.WINDOW_NAME, title=self.WINDOW_TITLE, width=self.WIDTH, height=self.HEIGHT,
  24.                            sizeable=True, minimizeButton=False, maximizeButton=False)
  25.         mc.window(self.window, edit=True, width=self.WIDTH, height=self.HEIGHT)
  26.  
  27.         self.mainLayout = mc.columnLayout('mainLayout', width=self.WIDTH)
  28.  
  29.         self.contentLayout = self.mainLayout
  30.  
  31.         if self.SCROLLABLE:
  32.             self.scrollLayout = mc.scrollLayout('scrollLayout', width=self.WIDTH, height=self.HEIGHT, parent=self.mainLayout)
  33.             self.contentLayout = mc.columnLayout('contentLayout', width=self.WIDTH - 16, parent=self.scrollLayout)
  34.  
  35.         self.CreateCustomUI()
  36.  
  37.         if self.dockable:
  38.             mc.dockControl(label=self.WINDOW_TITLE, area='right', content=self.window, allowedArea=self.allowedAreas)
  39.         # mc.showWindow(self.window)
  40.  
  41.     def CreateCustomUI(self):
  42.         """ """
  43.         print 'BaseWindow.CreateCustomUI Override this function in child classes'
  44.  
  45.  
  46. window = BaseWindow(dock=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement