예제 #1
0
 def set_options(self, *arg):
     for opt in self.options:
         if opt == "sizes":
             value = []
             if self.dock_ui:
                 value.append(pmc.dockControl(self.dock_ui, q=True, w=True))
                 value.append(pmc.dockControl(self.dock_ui, q=True, h=True))
             else:
                 value.append(pmc.window(self.win, q=True, w=True))
                 value.append(pmc.window(self.win, q=True, h=True))
             
             value.extend(pmc.paneLayout(self.main_layout, q=True, paneSize=True))
             value.extend(pmc.paneLayout(self.script_layout, q=True, paneSize=True))
         
         elif opt == "dock":
             if self.dock_ui:
                 value = [self.dock[0]]
                 value.append(int(pmc.dockControl(self.dock_ui, q=True, floating=True)))
                 tmp = pmc.dockControl(self.dock_ui, q=True, area=True)
                 for obj_id, a in self.dock_areas.iteritems():
                     if a == tmp:
                         break
                 else:
                     obj_id = self.dock[2]
                 value.append(obj_id)
             else:
                 value = getattr(self, opt)
         else:
             value = getattr(self, opt)
         
         opt_name = self.get_option_name(opt)
         pmc.optionVar[opt_name] = value
     
     self.update_pys()
예제 #2
0
def start():

    if pm.window('wBatchTools', ex=1):
        pm.deleteUI('wBatchTools')

    DOCK_NAME = 'BT_DOCK'
    LYT_NAME = 'BT_LYT_NAME'
    WIN_NAME = 'wBatchTools'
    AREA = 'left'

    app = BatchTools(mayaMainWindow)
    app.show()
    app.postLoad()

    # dock window
    if pm.dockControl(DOCK_NAME, ex=1):
        pm.deleteUI(DOCK_NAME)
    dockLayout = pm.paneLayout(LYT_NAME,
                               configuration='single',
                               parent=WIN_NAME,
                               width=500,
                               height=500)
    pm.dockControl(DOCK_NAME,
                   aa=['left', 'right'],
                   a=AREA,
                   floating=0,
                   content=dockLayout,
                   l='Batch tools')
    pm.control(WIN_NAME, e=True, parent=dockLayout)
    if pm.dockControl(DOCK_NAME, ex=1):
        pm.control(WIN_NAME, e=1, p=dockLayout)
        pm.dockControl(DOCK_NAME, e=1, a=AREA, fl=0)
        pm.dockControl(DOCK_NAME, e=1, vis=1)
        pm.dockControl(DOCK_NAME, e=1, w=500)
예제 #3
0
파일: maya.py 프로젝트: huntfx/vfxwindow
    def attachToDockControl(windowInstance, dock=True, area='right'):
        """This needs to be deferred as it can run before the previous dockControl has closed."""
        if isinstance(dock, (bool, int)):
            dock = 'right'
        if not windowInstance.objectName():
            windowInstance.setObjectName(windowInstance.WindowID)
        pm.dockControl(windowInstance.WindowID,
                       area=dock,
                       floating=False,
                       retain=False,
                       content=windowInstance.objectName(),
                       closeCommand=windowInstance.close)

        windowInstance.setDocked(dock)
        try:
            pm.dockControl(
                windowInstance.WindowID,
                edit=True,
                floatChangeCommand=windowInstance.saveWindowPosition)
        except (AttributeError, TypeError):
            pass

        try:
            windowInstance.deferred(windowInstance.loadWindowPosition)
        except (AttributeError, TypeError):
            pass

        windowInstance.setWindowTitle(
            getattr(windowInstance, 'WindowName', 'New Window'))
        windowInstance.deferred(windowInstance.raise_)
        windowInstance.deferred(windowInstance.windowReady.emit)
예제 #4
0
 def update_size_ui(self):
     if self.dock_ui and self.dock[0]:
         kwargs = self.__dock_kwargs()
         kwargs["e"] = True
         pmc.dockControl(self.dock_ui, **kwargs)
     else:
         self.win.setWidthHeight(self.sizes[:2])
     
     paneSizes = []
     tmp = self.sizes[2:8]
     j = 1
     for i in range(0, len(tmp) - 1, 2):
         paneSizes.append([j, tmp[i], tmp[i + 1]])
         j += 1
     pmc.paneLayout(self.main_layout, e=True, paneSize=paneSizes)
     
     pmc.paneLayout(self.script_layout, e=True,
                    paneSize=[
                              [1, self.sizes[8], self.sizes[10]],
                              [2, self.sizes[9], self.sizes[11]],
                              ]
                    )
     
     pmc.checkBoxGrp(self.order_ui, e=True, v1=self.order)
     pmc.checkBoxGrp(self.order_ui, e=True, v2=self.show_doc)
     
     pmc.optionMenuGrp(self.filter_test_ui, e=True, v=self.filter_test)
예제 #5
0
파일: gui.py 프로젝트: bohdon/viewGui
    def register(self):
        """ Register the dock in maya """
        self.deleteViews()
        
        # Dock
        if pm.dockControl(self.dockName, ex=True):
            pm.deleteUI(self.dockName)

        # Window
        if pm.window(self.winName, ex=True):
            pm.deleteUI(self.winName)
        
        self._win = None
        self.applyMetrics()

        # For a dockControl, we've got to go create the ui this way
        # otherwise when we create the dockControl it doesn't see the main layout
        self._win = pm.window(self.winName, title=self.title)
        with pm.frameLayout('mainForm', lv=False, bv=False, p=self._win) as self._mainLayout:
            self.mainControl = self._mainLayout

            # Create the dockControl
            self._dockControl = pm.dockControl(self.winName+"Dock",
                con=self._win, aa=['left', 'right'], a=self.area, fl=int(self.floating), l=self.title,
                vcc=Callback(self.dockVisibleChanged), vis=False,
            )
            self._win = self._mainLayout
            self.showDefaultView()

        pm.scriptJob(uid=(self._win, Callback(self.winClosed)))
예제 #6
0
 def setDocked(self, dock):
     if self.dockable() and self.floating() == dock:
         if self._Pre2017:
             self.raise_()
             pm.dockControl(self.WindowID, edit=True, floating=not dock)
             self.raise_()
         else:
             pm.workspaceControl(self.WindowID, edit=True, floating=not dock)
예제 #7
0
 def buildUI(self):
     
     # Make sure there are no duplicated UI
     if pc.window(self.windowName, exists=True):
         pc.deleteUI(self.windowName)
     if pc.dockControl(self.windowName+'_dock', exists=True):
         pc.deleteUI(self.windowName+'_dock')
     
     # Dock window
     self.uiWidgets['window'] = pc.window(self.windowName, title=self.windowName, h=self.windowHeight, w=self.windowWidth, mnb=False, mxb=False, sizeable=False)
     
     # Layout and dock
     self.uiWidgets['layout'] = pc.columnLayout(p=self.uiWidgets['window'])
     pc.dockControl(self.windowName+'_dock', label=self.windowName, area='right', content=self.uiWidgets['window'])
     
     #### Tabs and buttons creation
     # Categories list
     categories = {}
     
     # Check for file that has to be ignored
     ignoreFile = open(pc.internalVar(upd=True)+'scripts/'+self.scanFolder+'/ignore.txt')
     ignoredFiles = []
     for line in ignoreFile:
         ignoredFiles.append(line.replace('\n',''))
     
     # Check for existing *.py files in the script/self.scanFolder folder
     for pyscript in os.listdir(pc.internalVar(upd=True)+'scripts/'+self.scanFolder):
         if fnmatch.fnmatch(pyscript, '*.py') and pyscript not in ignoredFiles:
             # Get the category for later use
             category = pyscript.partition('_')[0]
             # If category is not empty
             if category != '':
                 if category not in categories.keys():
                     categories[category] = []
                 # Append the icon path associated to the script
                 print "Adding script '%s' to shelf." % pyscript
                 categories[category].append(pyscript.partition('.')[0]+'.png')
                 
     print categories
     
     for category in categories.keys():
         self.uiWidgets[category+'_frameLayout'] = pc.frameLayout(label=category.capitalize(), borderStyle='etchedIn', cll=True, w=self.windowWidth, parent=self.uiWidgets['layout'])
         
         self.uiWidgets[category+'_rcLayout']= pc.rowColumnLayout(nc=3, p=self.uiWidgets[category+'_frameLayout'])
         
         for icon in categories[category]:
             iconPath = pc.internalVar(upd=True)+'icons/'+self.scanFolder+'/'+icon
             # If icon exists, we use it
             if os.path.exists(iconPath):
                 pc.iconTextButton(w=35, h=35, i1=iconPath,c=partial(self.loadScript, icon.partition('.')[0]))
             else:
                 pc.iconTextButton(iol=icon.partition('.')[0].partition('_')[2], w=35, h=35, i1=pc.internalVar(upd=True)+'icons/'+self.scanFolder+'/missing.png',c=partial(self.loadScript, icon.partition('.')[0]))
예제 #8
0
    def createBrowser(self):
        win = pm.window(w=200)

        form = pm.formLayout(numberOfDivisions=100)
        col2 = pm.columnLayout(p=form, adjustableColumn=True)
        allowedAreas = ['right', 'left']
        pm.dockControl(label='BROWSER', w=200, area='left', content=win, allowedArea=allowedAreas)

        self.projectSelectWidget = ProjectSelectWidget()
        self.projectSelectWidget.createProjectSelect(col2)

        pm.rowLayout(nc=3, adj=1)
        self.typeOpt = pm.optionMenuGrp(label='Item Type', changeCommand=self.changeTypeCallback, cat=[[1,'left',5],[2,'left',-80]])
        types = ['asset', 'shot', 'model', 'uvs', 'texture', 'blendShape', 'rig', 'layout', 'animation',
                 'shotFinalizing', 'lightining', 'render']
        for assetType in types:
            pm.menuItem(label=assetType)

        pm.symbolButton(image=r'D:/JOBS/PIPELINE/pipeExemple/scenes/icons/small.png', c=lambda x, y=2: self.changeViewCallback(y))
        pm.symbolButton(image=r'D:/JOBS/PIPELINE/pipeExemple/scenes/icons/big.png', c=lambda x, y=1: self.changeViewCallback(y))

        pane = pm.paneLayout(p=form, configuration='top3', ps=[(1, 20, 80), (2, 80, 80), (3, 100, 20)], shp = 0)

        self.folderTreeWidget = FolderTreeWidget('asset')
        self.folderTreeWidget.createFolderTree(pane)
        self.folderTreeWidget.getFolderTree()

        self.itemListWidget = ItemListWidget()
        self.itemListWidget.createList(pane)
        self.itemListWidget.refreshList(path=[], task='asset')

        self.infoWidget = InfoWidget()
        self.infoWidget.createInfo(pane)

        self.folderTreeWidget.itemListWidget = self.itemListWidget
        self.folderTreeWidget.itemListWidget.type = 'asset'
        self.folderTreeWidget.itemListWidget.task = 'asset'
        self.projectSelectWidget.folderTreeWidget = self.folderTreeWidget
        self.projectSelectWidget.itemListWidget = self.itemListWidget
        self.itemListWidget.infoWidget = self.infoWidget

        pm.formLayout(form, edit=True,
                      attachForm=[(pane, 'left', 5), (pane, 'bottom', 5), (pane, 'right', 5),
                                  (col2, 'top', 5), (col2, 'left', 5), (col2, 'right', 5)],
                      attachControl=[(pane, 'top', 5, col2)],
                      attachPosition=[],
                      attachNone=()
                      )

        pm.showWindow()
예제 #9
0
def sortControlWidget(*a):
    s = SortControlLayout()

    if pm.dockControl('sortingDock', query=True, exists=True):
        pm.deleteUI('sortingDock')

    allowedAreas = ['right', 'left']

    dock = pm.dockControl('sortingDock',
                          floating=True,
                          label='Sorting / Team Switching',
                          area='left',
                          content=s,
                          allowedArea=allowedAreas)
예제 #10
0
def getDock(name='CoutureDock'):
    """
    Get the ptr to a dockable location for Couture
    @param name: str, name of the Couture dockable window
    @return ptr: ptr the dock windows newly created
    """

    deleteDock(name)

    if maya_api_version() < MAYA2017:
        ctrl = pm.dockControl(name,
                              area='right',
                              content='Couture',
                              allowedArea='all',
                              label="Couture tool",
                              vis=True,
                              r=True)
        print "do ctrl"

        # And then we return the control name
        return ctrl

    else:
        # ctrl = pm.workspaceControl(name, dockToMainWindow=('right', 1), label="Couture tool")
        ctrl = pm.workspaceControl(name,
                                   dockToMainWindow=('right', 1),
                                   label="Couture tool",
                                   loadImmediately=True,
                                   vis=True,
                                   r=True)
        qtCtrl = omui.MQtUtil_findControl(ctrl)
        ptr = wrapInstance(long(qtCtrl), QtWidgets.QWidget)

        return ptr
예제 #11
0
 def __init__(self, **kwargs):
     self.win = window(t= "adbrower - AutoRig v1.0" , tlb = True, s=True, rtf=True, w = 255)
     pm.scrollLayout(horizontalScrollBarThickness=16,verticalScrollBarThickness=16,)
     if pm.dockControl('adb_AutoRig', q=1, ex=1):
         pm.deleteUI('adb_AutoRig')
     self.ui()
     self.allgrey()
예제 #12
0
def getDock(name='LightingManagerDock'):
    """
    This function creates a dock with the given name.
    It's an example of how we can mix Maya's UI elements with Qt elements
    Args:
        name: The name of the dock to create

    Returns:
        QtWidget.QWidget: The dock's widget
    """
    # First lets delete any conflicting docks
    deleteDock(name)
    # Then we create a dockControl dock using Maya's UI tools
    # This gives us back the name of the dock created

    # <=Maya2016: In Maya 2016 and below, we just give our Light Managers object name to the dockControl.
    # You can see this name when we do self.setObjectName in the LightManagers __init__ method
    ctrl = pm.dockControl(name,
                          area='right',
                          content='lightingManager',
                          allowedArea='all',
                          label="Lighting Manager")

    # And then we return the control name
    return ctrl
예제 #13
0
    def dock_it(self):
        if self.maya_version >= 2011:
            if pmc.dockControl(self.dock_name, q=True, ex=True):
                pmc.deleteUI(self.dock_name)
            
            if self.dock[0]:
#                kw = self.__dock_kwargs()
                self.dock_ui = pmc.dockControl(self.dock_name, label=self.ui_name,
                                               content=self.win, r=True, **self.__dock_kwargs())
            else:
                self.dock_ui = None
                self.show_window()
        else:
            self.show_window()
        
        self.update_size_ui()
예제 #14
0
 def hide(self):
     """Hide the window."""
     if self.dockable():
         if MAYA_VERSION < 2017:
             return pm.dockControl(self.WindowID, edit=True, visible=False)
         return pm.workspaceControl(self.WindowID, edit=True, visible=False)
     return super(MayaWindow, self).hide()
예제 #15
0
파일: maya.py 프로젝트: huntfx/vfxwindow
 def floating(self):
     """Return if the window is floating."""
     if not self.dockable():
         return False
     if self._Pre2017:
         return pm.dockControl(self.WindowID, query=True, floating=True)
     return pm.workspaceControl(self.WindowID, query=True, floating=True)
예제 #16
0
파일: view.py 프로젝트: lefan2016/TDClass01
    def __init__(self):
        # Singleton
        MainUI.current_view = self

        # Make sure only one single Maya docker
        if pm.window(self.window_name, exists=True):
            pm.deleteUI(self.window_name)
        if pm.dockControl(self.docker_name, exists=True):
            pm.deleteUI(self.docker_name)

        # Setup basic UI
        self.win = pm.window(self.window_name)
        self.frm_lyt = pm.formLayout(numberOfDivisions=100)
        self.prj_omg = pm.optionMenu(label='Current Preset:', height=25,
                                     changeCommand=lambda *args: self.update(target=args[0]))
        self.new_btn = pm.button(parent=self.frm_lyt, label='New', command=self.new)
        self.save_btn = pm.button(parent=self.frm_lyt, label='Save', command=self.save)
        self.prs_lyt = pm.rowColumnLayout(parent=self.frm_lyt, numberOfColumns=2)

        self.frm_lyt.attachForm(self.prj_omg, 'left', 5)
        self.frm_lyt.attachPosition(self.prj_omg, 'right', 0, 60)
        self.frm_lyt.attachControl(self.new_btn, 'left', 5, self.prj_omg)
        self.frm_lyt.attachPosition(self.new_btn, 'right', 0, 80)
        self.frm_lyt.attachControl(self.save_btn, 'left', 5, self.new_btn)
        self.frm_lyt.attachForm(self.save_btn, 'right', 5)
        self.frm_lyt.attachControl(self.prs_lyt, 'top', 5, self.prj_omg)

        # Setup options UI based on template
        self.setters = []
        for preset in model.preset_template:
            pm.text(label='%s: ' % preset['label'], align='right')
            # If the preset has items, then it is enumerable, which can be represented by an optionMenu.
            # Otherwise a textField will do.
            creator, arg = (pm.optionMenu, 'value') if preset.get('_items', None) else (pm.textField, 'text')
            # Create the control and use preset's setter as its callback function
            opt_ctl = creator(parent=self.prs_lyt, changeCommand=preset['setter'])
            for lbl in preset.get('_items', []):
                pm.menuItem(parent=opt_ctl, label=lbl)
            # Save control's info for later use.
            self.setters.append({'label': preset['label'], 'control': opt_ctl, 'creator': creator, 'arg': arg})

        # Update options values
        self.update(init=True)

        # Add the window to a Maya docker
        pm.dockControl(self.docker_name, area='left', content=self.win,
                       allowedArea=['right', 'left'], label='Presets Manager')
예제 #17
0
 def show(self, *args, **kwargs):
     ''' '''
     if self.dockable:
         mainDock = pm.dockControl(self.dockName, label=self.windowName, area=self.startArea,
                                   content=self.mainWindow, allowedArea=self.allowedAreas, floating=self.floating,
                                   w=self.width, h=self.height)
     else:
         self.mainWindow.show()
예제 #18
0
 def hide(self):
     """Hide the window."""
     if self.dockable():
         if MAYA_VERSION < 2017:
             return pm.dockControl(self.WindowID, edit=True, visible=False)
         self.parent().setAttribute(QtCore.Qt.WA_DeleteOnClose, False)
         return pm.workspaceControl(self.WindowID, edit=True, visible=False)
     return super(MayaWindow, self).hide()
def main_GUI(docked=False):
	global windowWidth, windowHeight, isDocked, windowName, dockedWindow, marginWidth

	isDocked = docked
	windowWidth = 390
	marginWidth = windowWidth-12
	windowHeight = 700
	windowLabel = 'HP3D | Simple Lights GUI'
	windowName = 'hp3dSimpleLightsWin'

	# Colors
	global primary_componentColor, secondary_componentColor, windowColor, disabled_componentColor, frameColor
	primary_componentColor = [.261, .380, .393]
	secondary_componentColor = [.175, .198, .200]
	windowColor = [.300, .305, .305]
	disabled_componentColor = [.322, .384, .388]
	frameColor = [primary_componentColor[0]/1.5, primary_componentColor[1]/1.5, primary_componentColor[2]/1.5]

	if pm.window(windowName, q=True, ex=True):
		pm.deleteUI(windowName)
	if pm.windowPref(windowName, q=True, ex=True):
		pm.windowPref(windowName, r=True)
	if pm.dockControl(windowName, q=True, ex=True):
		pm.deleteUI(windowName)

	global window_obj
	window_obj = pm.window(windowName, 
		title=windowLabel,
		w=windowWidth, h=windowHeight,
		mnb=False, mxb=False, 
		bgc=windowColor)

	pm.scrollLayout(w=windowWidth+40,)
	pm.columnLayout()
	pm.rowColumnLayout(nr=2, rh=[1, 7])
	pm.text(l='') # GUI SPACER 
	pm.rowColumnLayout(nc=3, cw=[[1, 7], [3, 7]])
	pm.text(l='') # GUI SPACER 
	all_sections()
	pm.text(l='') # GUI SPACER 

	if docked == False:
		window_obj.show()
	elif docked == True:
		allowedAreas = ['right', 'left']
		dockedWindow = pm.dockControl(windowName, l=windowLabel, a='right', con=window_obj, aa=allowedAreas, visible=True)
예제 #20
0
 def setWindowTitle(self, title):
     if self.dockable():
         try:
             if self._Pre2017:
                 return pm.dockControl(self.WindowID, edit=True, label=title)
             return pm.workspaceControl(self.WindowID, edit=True, label=title)
         except RuntimeError:
             pass
     return super(MayaWindow, self).setWindowTitle(title)
예제 #21
0
 def isVisible(self):
     if self.dockable():
         try:
             if self._Pre2017:
                 return pm.dockControl(self.WindowID, query=True, visible=True)
             return pm.workspaceControl(self.WindowID, query=True, visible=True)
         except RuntimeError:
             return False
     return super(MayaWindow, self).isVisible()
예제 #22
0
def deleteDock(name='LightingManagerDock'):
    """
    A simple function to delete the given dock
    Args:
        name: the name of the dock
    """
    # We use the dockControl to see if the dock exists
    if pm.dockControl(name, query=True, exists=True):
        # If it does we delete it
        pm.deleteUI(name)
예제 #23
0
 def resize(self, width, height=None):
     """Resize the window."""
     if isinstance(width, QtCore.QSize):
         height = width.height()
         width = width.width()
     if self.dockable():
         if self._Pre2017:
             if not self.floating():
                 return pm.dockControl(self.WindowID, edit=True, width=width, height=height)
         else:
             return pm.workspaceControl(self.WindowID, edit=True, resizeWidth=width, resizeHeight=height)
     return super(MayaWindow, self).resize(width, height)
예제 #24
0
def deleteDock(name='CoutureDock'):
    """
    Delete an already existing Couture dockable windows
    @param name: str, name of the Couture dockable window
    """
    if maya_api_version() < MAYA2017:
        if pm.dockControl(name, query=True, exists=True):
            # If it does we delete it
            pm.deleteUI(name)
    else:
        if pm.workspaceControl(name, query=True, exists=True):
            pm.deleteUI(name)
예제 #25
0
 def __init__(self, **kwargs):
     self.win = pm.window(t="adbrower - Module v1.0",
                          tlb=True,
                          s=True,
                          rtf=True)
     pm.scrollLayout(
         horizontalScrollBarThickness=16,
         verticalScrollBarThickness=16,
     )
     if pm.dockControl('adb_Module', q=1, ex=1):
         pm.deleteUI('adb_Module')
     self.ui()
예제 #26
0
def show():

    if pmc.window("colorKeyWindow", q=True, exists=True):
        pmc.deleteUI("colorKeyWindow")

    if pmc.paneLayout('colorKeyPane', q=True, exists=True):
        pmc.deleteUI('colorKeyPane')

    if pmc.dockControl('colorKeyDocked', q=True, exists=True):
        pmc.deleteUI('colorKeyDocked')

    dialog = ColorKeyUI(getMayaWindow())
    dialog.show()
예제 #27
0
def nicoleGUI():

	global windowWidth, windowHeight, mainColumnLayout, riggingLayout
	windowWidth = 325
	windowHeight = 600

	windowName = "Rigging Toolset"

	if pm.dockControl("Toolset", ex = True):
	   pm.deleteUI("Toolset", uit = True)


	window_object = pm.window(windowName, w = windowWidth, h = windowHeight, t = "toolSet")
	allowedAreas = ["right", "left"]

	scrollFieldColumnLayout = rcl(nc = 1)
	scrollField = pm.scrollLayout(w = (windowWidth)+30, h = windowHeight)
	mainColumnLayout = rcl(nc = 1)

	riggingLayout()

	pm.dockControl(l = "Nicole Krason's GUI", a = "right", con = window_object, aa = allowedAreas)
예제 #28
0
def makeDockable(childWidget, areaName, width, label):
	
	slider = pm.floatSlider() #some throwaway control, feel free to delete this when you're done.
	dock = pm.dockControl(l = label, content=slider,  area = areaName, w = width ) #Returns the string path to the dock control. The control is a QDockWidget under the hood.
	dockPt = openMayaUi.MQtUtil.findControl(dock) #Find the pointer to the dock control
	dockWidget = sip.wrapinstance(long(dockPt), QtCore.QObject) #Get that pointer as a Qt widget
	childWidget.setParent(dockWidget)
	dockWidget.setWidget(childWidget) #Set the docked widget to be your custom control.




	
예제 #29
0
def dockPanel(panel):
    """
    Put the widget to the Maya's dock.

    Args:
        panel: the widget to put
    """
    # Retrieve the panel name.
    panel_name = panel.objectName()

    # Create a Maya panel name.
    maya_panel_name = "maya_%s" % panel_name

    # Create a new Maya window.
    maya_window = pm.window()

    # Add a layout to the Maya window.
    maya_layout = pm.formLayout(parent=maya_window)

    # Reparent the panel under the Maya window layout.
    pm.control(panel_name, edit=True, parent=maya_layout)

    attachForm = [(panel_name, 'top', 1), (panel_name, 'left', 1),
                  (panel_name, 'bottom', 1), (panel_name, 'right', 1)]

    # Keep the panel sides aligned with the Maya window layout sides.
    pm.formLayout(maya_layout, edit=True, attachForm=attachForm)

    # Dock the Maya window into a new tab of Maya Channel Box dock area.
    pm.dockControl(maya_panel_name,
                   area="left",
                   content=maya_window,
                   label=PANEL_NAME)

    # Once Maya will have completed its UI update and be idle,
    # raise (with "r=True") the new dock tab to the top.
    maya.utils.executeDeferred("import maya.cmds as cmds\n"
                               "cmds.dockControl('%s', edit=True, r=True)" %
                               maya_panel_name)
예제 #30
0
파일: UI.py 프로젝트: adamfok/afok_toolset
    def show(self):
        if self.dock :
            if pm.dockControl(self.window+"_dock", exists = True):
                pm.deleteUI(self.window+"_dock")
        else:
            if pm.window (self.window, exists = True) :
                pm.deleteUI (self.window)
            
        if pm.windowPref(self.window, exists=True ):
            pm.windowPref(self.window, remove=True ) 

        # Initalise Window Layout
        self.widgets["window"] = pm.window(self.window,
                                           title=self.title,
                                           sizeable=self.dock or self.sizeable,
                                           mnb=False,
                                           mxb=False,
                                           width=self.windowWidth,
                                           height=self.windowHeight)
        
        self.widgets["master_layout"] = pm.verticalLayout()
        
        # Initalise Layout
        self.initialiseLayout()
        
        # Redistribute Layout
        self.widgets["master_layout"].redistribute()
        
        if self.dock:
            pm.dockControl(self.window + "_dock",
                           label = self.title,
                           area=self.allowArea[0],
                           allowedArea=self.allowArea ,
                           content = self.window)
        else:
            pm.showWindow(self.window)
        
        return self.widgets["window"]
예제 #31
0
def makeDockable(childWidget, areaName, width, label):

    slider = pm.floatSlider(
    )  #some throwaway control, feel free to delete this when you're done.
    dock = pm.dockControl(
        l=label, content=slider, area=areaName, w=width
    )  #Returns the string path to the dock control. The control is a QDockWidget under the hood.
    dockPt = openMayaUi.MQtUtil.findControl(
        dock)  #Find the pointer to the dock control
    dockWidget = sip.wrapinstance(
        long(dockPt), QtCore.QObject)  #Get that pointer as a Qt widget
    childWidget.setParent(dockWidget)
    dockWidget.setWidget(
        childWidget)  #Set the docked widget to be your custom control.
예제 #32
0
 def dock(self, *args):
     if self.docker==None:
         allowedAreas = ['right', 'left']
         self.docker = pm.dockControl(area='left', content=self.window, allowedArea=allowedAreas, label=self.title, w=self.wh[0])
     else:
         docker_exists = pm.dockControl(self.docker, q=True, ex=True)
         print docker_exists
         if docker_exists and pm.dockControl(self.docker, q=True, fl=True):
             print 'It Doesn\'t Float.'
             pm.dockControl(self.docker, e=True, fl=False)
             #pm.deleteUI(self.docker)
             #self.docker=None
             #TODO: (reinitialize window)
             #self.__reinit__()
         else:
             print 'It floats!'
             pm.dockControl(self.docker, e=True, fl=True)
예제 #33
0
 def _buildupWindow(self):
     if self._dockControl and self._dockControl.exists(self._winTitle):
         _pmCore.deleteUI(self._dockControl)
     self._window = _pmCore.window(title=self._winTitle)
     
     _pmCore.columnLayout()
     self._dockControl = _pmCore.dockControl(area='right', content=self._window, label=self._winTitle)
     tabLayout = _pmCore.tabLayout()
     self._uiWidget[_UiWidgetEnum.categoryTabLayout] = tabLayout
     for category in _Database.getCategoryList():
         childLayout = _pmCore.scrollLayout(width=300, height=300, childResizable=True)
         self._uiWidget[category] = _pmCore.gridLayout(numberOfColumns=3, cellHeight = self._iconSize, cellWidth=self._iconSize)
         for assetInfo in _Database.getAssetUnderCategory(category):
             id, sceneName, _, versionID, _, _, _ = assetInfo
             self._addAssetButton(id, sceneName, versionID)
         _pmCore.tabLayout(tabLayout, tabLabel=((childLayout, category),), edit=True)
         _pmCore.setParent('..')
         _pmCore.setParent('..')
         
     _pmCore.setParent('..')
     
     self._uiWidget[_UiWidgetEnum.sceneNameTextField] = _pmCore.textFieldGrp(label='Scene Name: ', width=300, columnAlign2=['left', 'left'], columnWidth2=[100, 195])
     self._uiWidget[_UiWidgetEnum.filePathTextField] = _pmCore.textFieldGrp(label='File Path: ', width=300, columnAlign2=['left', 'left'], columnWidth2=[100, 195])
     _pmCore.rowLayout(numberOfColumns=2)
     _pmCore.text(label="Current Version:", width=100, align='left')
     self._uiWidget[_UiWidgetEnum.versionNumText] = _pmCore.text(label="")
     _pmCore.setParent('..')
     self._uiWidget[_UiWidgetEnum.categoryCombox] = _pmCore.optionMenuGrp(label='Category: ', width=300, columnAlign2=['left', 'left'], columnWidth2=[100, 195])
     for category in _Database.getCategoryList():
         self._uiWidget.setdefault(_UiWidgetEnum.categoryMenuList, []).append(_pmCore.menuItem(label=category))
     _pmCore.text(label='Description:')
     self._uiWidget[_UiWidgetEnum.descriptionTextField] = _pmCore.scrollField(width=300, height=50)
 
     _pmCore.separator(style='single', horizontal=True)
     _pmCore.gridLayout(numberOfColumns=2, cellWidth=150)
     self._uiWidget[_UiWidgetEnum.updateAssetBtn] = _pmCore.button(label='Update Asset Info', command=_pmCore.Callback(self._updateAssetClicked))
     self._uiWidget[_UiWidgetEnum.addCommentBtn] = _pmCore.button(label='View Version & Comment', command=_pmCore.Callback(self._viewVersionListClicked))
     self._uiWidget[_UiWidgetEnum.addAssetBtn] = _pmCore.button(label='Add New Asset', command=_pmCore.Callback(self._addAssetClicked))
     self._uiWidget[_UiWidgetEnum.deleteAssetBtn] = _pmCore.button(label='Delete Asset', command=_pmCore.Callback(self._deleteAssetClicked))
     self._uiWidget[_UiWidgetEnum.addVersionBtn] = _pmCore.button(label='Add Version', command=_pmCore.Callback(self._addVersionClicked))
     self._uiWidget[_UiWidgetEnum.manageCategoryBtn] = _pmCore.button(label='Manage Category', command=self._manageCategoryClicked)
     
     _pmCore.setParent('..')
예제 #34
0
def deleteDockControl(windowID):
    """Handle deleting a dockControl with a particular ID."""
    # Get current floating state
    if pm.dockControl(windowID, query=True, exists=True):
        floating = pm.dockControl(windowID, query=True, floating=True)
        pm.dockControl(windowID, edit=True, r=True)
        pm.dockControl(windowID, edit=True, floating=False)
    else:
        floating = None

    # Close down the dock control
    windowWrap = getMainWindow(windowID)
    if windowWrap is not None:
        if windowWrap.parent().parent() is not None:
            getMainWindow(windowID).parent().close()

    if floating is not None:
        try:
            pm.dockControl(windowID, edit=True, floating=floating)
        except RuntimeError:
            pass

    return floating
예제 #35
0
def create(docked=True):
    global dialog
    if dialog is None:
        dialog = InterpolateIt()

    if docked is True:

        size = dialog.size()

        name = 'MayaWindow|InterpolateIt'
        dock = pm.dockControl(allowedArea=['right', 'left'],
                              area='right',
                              floating=False,
                              content=name,
                              width=size.width(),
                              height=size.height(),
                              label='Interpolate It')

        widget = OpenMayaUI.MQtUtil.findControl(dock)
        dock_widget = wrapInstance(long(widget), QtCore.QObject)

    dialog.show()
예제 #36
0
 def area(self, *args, **kwargs):
     """Return the Maya area name."""
     return pm.dockControl(self.WindowID, query=True, area=True)
예제 #37
0
 def floating(self):
     if self._Pre2017:
         return pm.dockControl(self.WindowID, query=True, floating=True)
     return pm.workspaceControl(self.WindowID, query=True, floating=True)
예제 #38
0
파일: gui.py 프로젝트: bohdon/viewGui
 def dockVisibleChanged(self):
     if pm.dockControl(self._dockControl, ex=True):
         if not pm.dockControl(self._dockControl, q=True, vis=True):
             self.mainLayout.clear()
         else:
             self._updateViews()
예제 #39
0
 def closeDock(self, arg):
     if not pm.dockControl(self.docker, q=True, vis=True):
         pm.deleteUI(self.docker)
예제 #40
0
파일: gui.py 프로젝트: bohdon/viewGui
 def toggleDock(self):
     if pm.dockControl(self.dockControl, q=True, vis=True):
         self.hideDock()
     else:
         self.showDock()
예제 #41
0
 def exists(self):
     if self.dockable():
         if self._Pre2017:
             return pm.dockControl(self.WindowID, query=True, exists=True)
         return pm.workspaceControl(self.WindowID, query=True, exists=True)
     return not self.isClosed()
예제 #42
0
def main(*args):

	if pm.window('riggingToolkitWindow', exists = True):
	    pm.deleteUI('riggingToolkitWindow', window = True) 
	    print 'Pre-existing window ToolKit deleted'

	if pm.dockControl('riggingToolkitDockControl', exists = True):
		pm.deleteUI('riggingToolkitDockControl', control = True)


	#Declarations
	global windowWidth
	global windowHeight
	global jointChainLenField
	global nameField
	global suffixField
	global typeIndex
	global stretchyCheckBox

	global newNameField
	global newSuffixField

	windowWidth = 325
	windowHeight = 100000
	allowedAreas = ['left', 'right']
	buttonIndex = 0
	typeIndex = 0


	childFrameWidth = windowWidth - 5

	window_object = pm.window('riggingToolkitWindow', t = 'Rigging Toolkit', width = windowWidth, height = windowHeight, sizeable = False)

	scrollFieldColumnLayout = pm.rowColumnLayout(nc = 1)
	scrollField = pm.scrollLayout(w = 350, h = 600)
	mainColumnLayout = pm.rowColumnLayout(nc = 1)
	jointFrameLayout = pm.frameLayout('jointLayout', cll = True, cl = False, width = windowWidth, l = 'Joint Layout')

	jointChainColumn = pm.rowColumnLayout(nc = 2)

	pm.text(l = 'Name', al = 'center', width = windowWidth/2)
	pm.text(l = 'Suffix', al = 'center', width = windowWidth/2)
	nameField = pm.textField()
	suffixField = pm.textField()

	pm.setParent(jointFrameLayout)
	worldColumn = pm.rowColumnLayout(nc = 2)
	pm.button(l = 'Define World', w = (windowWidth/6) * 5, c = defineWorld)
	pm.button(l = 'Set', w = windowWidth/6, c = setWorld)

	pm.setParent(jointFrameLayout)

	jointChainColumnSecondary = pm.rowColumnLayout(nc = 2)

	jointChainLenField = pm.textField(w = windowWidth/8, tx = '5')
	jointChainButton = pm.button(l = 'Create Joint Chain', c = createJointChain, w = ((windowWidth/8)*7))

	pm.setParent(jointFrameLayout)

	radioButtonRColmn = pm.rowColumnLayout(nc = 2)
	jntChnTypRadioCollection = pm.radioCollection()
	normChain = pm.radioButton(l = 'Normal', w = windowWidth/2, onc = lambda *args: buttonIndexUpdate(0))
	ribnChain = pm.radioButton(l = 'Ribbon', w = windowWidth/2, onc = lambda *args: buttonIndexUpdate(1))

	pm.setParent(mainColumnLayout)	
	jointSetupFrmLyt = pm.frameLayout('jointSetup', cll = True, cl = True, w = windowWidth, l = 'Joint Setup')
	separatorText('Spine Setup')
	spineTypeClmnLyt = pm.rowColumnLayout(nc = 2)
	pm.button(l = 'Schleifer', c = schleiferify, w = (windowWidth/2))
	pm.button(l = 'Ribbon', c = folliclify, w = windowWidth/2)

	pm.setParent(jointSetupFrmLyt)
	separatorText('Switch Setup')

	fkIkSpineClmnLyt = pm.rowColumnLayout(nc = 2)
	pm.button(l = 'Fk', c =  lambda *args: makeFk( False, pm.ls(selection = True)[0]), w = windowWidth/2)
	pm.button(l = 'Ik', c = lambda *args: makeIk( False, pm.ls(selection = True)[0]), w = windowWidth/2)
	pm.setParent(jointSetupFrmLyt)
	pm.button(l = 'Fk Ik', c = makeFkIk, w = windowWidth)
	stretchyCheckBox = pm.checkBox(l = 'Stretchy', v = 0)

	footRollSetup = pm.frameLayout('footRollSetup', cll = True, cl = True, w = windowWidth, l = 'FootRoll Setup')
	separatorText('Setup')
	footRollRowCol = pm.rowColumnLayout( nc = 2)
	pm.button(l = 'Setup', c = setupFootRoll, w = childFrameWidth * 0.7)
	pm.button(l = 'Accept', c = acceptFootRoll, w = childFrameWidth * .3)

	pm.setParent(mainColumnLayout)
	miscFrmLyt = pm.frameLayout('miscTools', cll = True, cl = True, w = windowWidth, l = 'Miscellaneous Tools')
	renameFrmLyt = pm.frameLayout('renameTool', cll = True, cl = True, w = windowWidth, l = 'Joint Tools')
	jointChainColumn = pm.rowColumnLayout(nc = 2)

	pm.text(l = 'Name', al = 'center', width = windowWidth/2)
	pm.text(l = 'Suffix', al = 'center', width = windowWidth/2)
	newNameField = pm.textField(w = windowWidth/2, pht = "Type Name Here")
	newSuffixField = pm.textField(w = windowWidth/2, pht = "Type Suffix Here")
	pm.setParent(renameFrmLyt)
	pm.button(l = 'Rename', c = jointChainRename, w = windowWidth)
	pm.button(l = 'Pad', c = createPad, w = windowWidth)
	pm.button(l = 'Select hierarchy', c = lambda *args: pm.select(hi = True), w = windowWidth)


	pm.setParent(miscFrmLyt)
	ctrlsFrmLyt = pm.frameLayout('ctrlTools', cll = True, cl = True, w = windowWidth, l = 'Control Tools')
	separatorText('Controls')
	pm.button(l = 'Edit Controls', c = editControls, w = windowWidth)
	pm.button(l = 'SDK Creator', c = lambda *args: customSdk.gui(), w = windowWidth)


	pm.setParent(miscFrmLyt)
	visualScaleFrmLyt = pm.frameLayout(label = 'Visual Scale', cll = True, cl = True)

	separatorText('Visual Scale')

	jointSize = 1.00
	ikSize = 1.00

	pm.columnLayout(columnOffset = ['left', -100], adjustableColumn = True, cal = 'left')
	jointSizeSliderObject = pm.floatSliderGrp(min = 0.001, max = 10, l = 'Joint Size', pre = 2, f = True, v = jointSize, cc = changeJointScale, dc = changeJointScale, adjustableColumn = True,)

	ikSizeSliderObject = pm.floatSliderGrp(min = 0.001, max = 10, l = 'IK Size', f = True, v = ikSize, cc = changeIKScale, dc = changeIKScale, adjustableColumn = True)

	pm.setParent(miscFrmLyt)
	facialFrame = pm.frameLayout('facialTools', cll = True, cl = True, w = windowWidth, l = 'Facial Tools')
	separatorText('Direct Connect')
	directConRowCol = pm.rowColumnLayout(nc = 3)
	pm.button(l = 'Trans', c = conTrans, w = windowWidth/3)
	pm.button(l = 'Rot', c = conRot, w = windowWidth/3)
	pm.button(l = 'Scale', c = conScale, w = windowWidth/3)

	pm.setParent(miscFrmLyt)
	geoFrame = pm.frameLayout('geometryTools', cll = True, cl = True, w = windowWidth, l = 'Geometry Tools')
	pm.text(l = 'Geometry', al = 'center', w = windowWidth)
	pm.rowColumnLayout(nc = 2)
	pm.button(l = 'Reference', c = refGeo, w = windowWidth/2)
	pm.button(l = 'Unreference', c = unRefGeo, w = windowWidth/2)
	pm.setParent(geoFrame)
	pm.text(l = 'Accessories', al = 'center', w = windowWidth)
	pm.rowColumnLayout(nc = 2)
	pm.button(l = 'Hide', c = hideAcc, w = windowWidth/2)
	pm.button(l = 'Unhide', c = unHideAcc, w = windowWidth/2)
	pm.dockControl('riggingToolkitDockControl', l = 'Rigging Toolkit', area = 'right', content = window_object, allowedArea = allowedAreas)
예제 #43
0
파일: gui.py 프로젝트: bohdon/viewGui
 def showDock(self):
     pm.dockControl(self.dockControl, e=True, vis=True)
예제 #44
0
def ui_main():

	windowName = 'msAnimRemap'
	dockWidth = 250

	beam = pA.PointA()
	mark = pB.PointB()

	if pm.dockControl(windowName, q= 1, ex= 1):
		pm.dockControl(windowName, e= 1, vis= 0)
		pm.deleteUI(windowName, lay= 1)

	main_window = pm.window()
	mainForm = pm.formLayout(p= main_window)
	copypasteField = pm.cmdScrollFieldExecuter(vis= 0, p= mainForm)

	bannerArea = pm.columnLayout(adj= 1)
	bannerTxt = pm.text(l= 'AniRemap', w= dockWidth)
	QBannerTxt = mqt.convert(bannerTxt)
	QBannerTxt.setStyleSheet('QObject {font: bold 42px; color: #222222;}')
	pm.setParent('..')

	versioArea = pm.columnLayout(adj= 1)
	versioTxt = pm.text(l= 'v'+mAniRemap.__version__)
	QVersioTxt = mqt.convert(versioTxt)
	QVersioTxt.setStyleSheet('QObject {font: bold 10px; color: #777777;}')
	pm.setParent('..')
	
	sep______1 = pm.separator(st= 'in', w= dockWidth - 8)

	panelTxt_1 = pm.text(l= 'Transfer Settings', al= 'left')
	QpanelTxt_1 = mqt.convert(panelTxt_1)
	QpanelTxt_1.setStyleSheet('QObject {font: 12px; color: #777777;}')

	trans_Area = pm.columnLayout(adj= 1, rs= 2)

	role_group = pm.columnLayout(adj= 1, rs= 2)
	pm.text('Role', al= 'left')
	cmC = pm.columnLayout()
	role_mqsb = mqsb.SwitchBox(onl= 'Source', ofl= 'Target', w= dockWidth - 42, h= 28, v= True, \
		p= cmC, ofbg= [148, 106, 68], onbg= [72, 120, 138])
	pm.setParent('..')
	pm.setParent('..')

	pm.rowLayout(nc= 2, adj= 1, cal= [1, 'right'])

	maya_group = pm.columnLayout(adj= 1, rs= 2)
	pm.text('Maya', al= 'left')
	cmA= pm.columnLayout()
	maya_mqsb = mqsb.SwitchBox(onl= 'Cross', ofl= 'Alone', w= (dockWidth-46)/2, h= 20, v= True, p= cmA)
	pm.setParent('..')
	pm.setParent('..')

	mode_group = pm.columnLayout(adj= 1, rs= 2)
	pm.text('Mode', al= 'left')
	cmB = pm.columnLayout()
	mode_mqsb = mqsb.SwitchBox(onl= 'LAN', ofl= 'Local', w= (dockWidth-46)/2, h= 20, p= cmB)
	pm.setParent('..')
	pm.setParent('..')

	pm.setParent('..')

	pm.setParent('..')
	
	sep______2 = pm.separator(st= 'in', w= dockWidth - 8)

	targetLabel = 'Target Settings' if True else 'Target Info'
	panelTxt_2 = pm.text(l= targetLabel, al= 'left')
	QpanelTxt_2 = mqt.convert(panelTxt_2)
	QpanelTxt_2.setStyleSheet('QObject {font: 12px; color: #777777;}')

	targe_Area = pm.columnLayout(adj= 1, rs= 5)
	
	targetAlone = pm.columnLayout(adj= 1, rs= 5, vis= 0)
	trg_sls = pm.textScrollList(w= 180, h= 50)
	pm.rowLayout(nc= 3, adj= 1, cal= [1, 'right'])
	svt_btn = pm.button(l= 'Save Target', bgc= [0.40, 0.37, 0.31])
	adt_btn = pm.button(l= '+', w= 20)
	rmt_btn = pm.button(l= '-', w= 20)
	pm.setParent('..')
	pm.setParent('..')

	targetCross = pm.columnLayout(adj= 1, rs= 5)
	pm.rowLayout(nc= 2, adj= 1, cal= [1, 'right'])
	tcHost_lbe = pm.text('Host : ', en= 0)
	tcHost_txt = pm.textField(w= 140, en= 0)
	pm.setParent('..')
	pm.rowLayout(nc= 2, adj= 1, cal= [1, 'right'])
	pm.text('Port : ')
	tcPort_txt = pm.textField(w= 140)
	pm.setParent('..')
	srcAddr = pm.rowLayout(nc= 2, adj= 1, cal= [1, 'right'])
	ch_btn = pm.button(l= 'Connect', bgc= [0.40, 0.37, 0.31])
	ps_btn = pm.button(l= 'Paste', w= 50)
	pm.setParent('..')
	disAddr = pm.rowLayout(nc= 2, adj= 1, cal= [1, 'right'], vis= 0)
	op_btn = pm.button(l= 'Open', bgc= [0.40, 0.37, 0.31])
	cp_btn = pm.button(l= 'Copy', w= 50)
	pm.setParent('..')
	pm.setParent('..')

	pm.setParent('..')

	sep______3 = pm.separator(st= 'in', w= dockWidth - 8)

	panelTxt_3 = pm.text(l= 'Remap Settings', al= 'left')
	QpanelTxt_3 = mqt.convert(panelTxt_3)
	QpanelTxt_3.setStyleSheet('QObject {font: 12px; color: #777777;}')

	remap_Area = pm.columnLayout(adj= 1, rs= 5)
	
	pm.rowLayout(nc= 2, cal= [1, 'right'], h= 20)
	pm.text('Match : ', w= 45, al= 'right')
	match_mnu = pm.optionMenu(w= 120)
	pm.menuItem('name')
	pm.menuItem('order')
	pm.setParent('..')

	tirm_group = pm.rowLayout(nc= 2, adj= 2, cal= [1, 'right'], h= 20)
	pm.text('Time : ', w= 45, al= 'right')
	cmD = pm.columnLayout()
	tirm_mqsb = mqsb.SwitchBox(onl= 'Slider', ofl= 'Entire', w= 120, h= 18, v= False, \
		p= cmD, ofbg= [62, 58, 60], onbg= [88, 90, 95])
	pm.setParent('..')
	pm.setParent('..')

	hSrc_group = pm.rowLayout(nc= 2, adj= 2, cal= [1, 'right'], h= 20)
	pm.text('Source : ', w= 45, al= 'right')
	cmE = pm.columnLayout()
	hSrc_mqsb = mqsb.SwitchBox(onl= 'Hierachy', ofl= 'Selected', w= 120, h= 18, v= True, \
		p= cmE, ofbg= [62, 58, 60], onbg= [88, 90, 95])
	pm.setParent('..')
	pm.setParent('..')

	hTrg_group = pm.rowLayout(nc= 2, adj= 2, cal= [1, 'right'], h= 20)
	pm.text('Target : ', w= 45, al= 'right')
	cmF = pm.columnLayout()
	hTrg_mqsb = mqsb.SwitchBox(onl= 'Hierachy', ofl= 'Selected', w= 120, h= 18, v= True, \
		p= cmF, ofbg= [62, 58, 60], onbg= [88, 90, 95])
	pm.setParent('..')
	pm.setParent('..')

	pm.rowLayout(nc= 2, cal= [1, 'right'], h= 20)
	pm.text('Scale : ', w= 45, al= 'right')
	scale_flt = pm.floatField(v= 1, pre= 2, w= 120)
	pm.setParent('..')

	pm.rowLayout(nc= 2, adj= 2, cal= [1, 'right'], h= 20)
	pm.text('Mirror : ', w= 45, al= 'right', en= 1)
	pm.radioButtonGrp('mirror_radioBtnGrp', nrb= 4, la4= ['None', 'Y Z', 'Y X', 'X Z'], ad4= 1, \
		cw4= [50, 35, 35, 35], sl= 1, en= 1)
	pm.setParent('..')

	pm.setParent('..')
	
	sep______4 = pm.separator(st= 'in', w= dockWidth - 8)

	exect_Area = pm.columnLayout(adj= 1, rs= 5, h= 46)

	remap_btn = pm.button(l= 'Remap Animation Curves', w= dockWidth - 30, h= 40)
	pm.setParent('..')


	pm.formLayout(mainForm, e= 1, af= [(bannerArea, 'top', -6)])
	pm.formLayout(mainForm, e= 1, af= [(versioArea, 'top', 40), (versioArea, 'right', 50)])
	pm.formLayout(mainForm, e= 1, af= [(sep______1, 'top', 58)])
	pm.formLayout(mainForm, e= 1, af= [(panelTxt_1, 'top', 64)])
	pm.formLayout(mainForm, e= 1, af= [(trans_Area, 'top', 84), (trans_Area, 'left', 15)])
	pm.formLayout(mainForm, e= 1, af= [(sep______2, 'top', 182)])
	pm.formLayout(mainForm, e= 1, af= [(panelTxt_2, 'top', 188)])
	pm.formLayout(mainForm, e= 1, af= [(targe_Area, 'top', 210), (targe_Area, 'left', 31)])
	pm.formLayout(mainForm, e= 1, af= [(sep______3, 'top', 304)])
	pm.formLayout(mainForm, e= 1, af= [(panelTxt_3, 'top', 310)])
	pm.formLayout(mainForm, e= 1, af= [(remap_Area, 'top', 332), (remap_Area, 'left', 20)])
	pm.formLayout(mainForm, e= 1, af= [(sep______4, 'top', 488)])
	pm.formLayout(mainForm, e= 1, af= [(exect_Area, 'top', 496), (exect_Area, 'left', 10)])


	def maya_mqsb_switch(status, *args):
		pm.columnLayout(targetAlone, e= 1, vis= 0 if status else 1)
		pm.columnLayout(targetCross, e= 1, vis= 1 if status else 0)
		pm.columnLayout(mode_group, e= 1, en= 1 if status else 0)
		pm.columnLayout(role_group, e= 1, en= 1 if status else 0)
		if status:
			pm.columnLayout(remap_Area, e= 1, en= 1 if role_mqsb.isChecked() else 0)
			pm.columnLayout(exect_Area, e= 1, en= 1 if role_mqsb.isChecked() else 0)
		else:
			pm.columnLayout(remap_Area, e= 1, en= 1)
			pm.columnLayout(exect_Area, e= 1, en= 1)
	maya_mqsb.onCmd = partial(maya_mqsb_switch, 1)
	maya_mqsb.offCmd = partial(maya_mqsb_switch, 0)

	def mode_mqsb_switch(status, *args):
		pm.text(tcHost_lbe, e= 1, en= 1 if status else 0)
		pm.textField(tcHost_txt, e= 1, tx= '', en= 1 if status else 0)
		pm.textField(tcPort_txt, e= 1, tx= '')
	mode_mqsb.onCmd = partial(mode_mqsb_switch, 1)
	mode_mqsb.offCmd = partial(mode_mqsb_switch, 0)

	def role_mqsb_switch(status, *args):
		pm.rowLayout(srcAddr, e= 1, vis= 1 if status else 0)
		pm.rowLayout(disAddr, e= 1, vis= 0 if status else 1)
		pm.textField(tcHost_txt, e= 1, tx= '', ed= 1 if status else 0)
		pm.textField(tcPort_txt, e= 1, tx= '', ed= 1 if status else 0)
		pm.columnLayout(remap_Area, e= 1, en= 1 if status else 0)
		pm.columnLayout(exect_Area, e= 1, en= 1 if status else 0)
	role_mqsb.onCmd = partial(role_mqsb_switch, 1)
	role_mqsb.offCmd = partial(role_mqsb_switch, 0)

	def op_btn_openPort(*args):
		addr = ''
		mode = 'LAN' if mode_mqsb.isChecked() else 'local'
		port_on = mark._portStatus()[0]
		if port_on:
			for p in port_on:
				if mode == 'LAN' and port_on[p]['ipaddr'].split(':')[0]:
					addr = port_on[p]['ipaddr']
				if mode == 'local' and not port_on[p]['ipaddr'].split(':')[0]:
					addr = port_on[p]['ipaddr']
		if not addr:
			addr = mark.portOpen(mode, 'python')
		host = addr.split(':')[0]
		port = addr.split(':')[1]
		pm.textField(tcHost_txt, e= 1, tx= str(host))
		pm.textField(tcPort_txt, e= 1, tx= str(port))
	pm.button(op_btn, e= 1, c= op_btn_openPort)

	def copyAddr(*args):
		host = pm.textField(tcHost_txt, q= 1, tx= 1)
		port = pm.textField(tcPort_txt, q= 1, tx= 1)
		addr = host + ':' + port
		pm.cmdScrollFieldExecuter(copypasteField, e= 1, clr= 1)
		pm.cmdScrollFieldExecuter(copypasteField, e= 1, t= addr)
		pm.cmdScrollFieldExecuter(copypasteField, e= 1, sla= 1)
		pm.cmdScrollFieldExecuter(copypasteField, e= 1, cp= 1)
	pm.button(cp_btn, e= 1, c= copyAddr)

	def pasteAddr(*args):
		pm.cmdScrollFieldExecuter(copypasteField, e= 1, clr= 1)
		pm.cmdScrollFieldExecuter(copypasteField, e= 1, pst= 1)
		addr = pm.cmdScrollFieldExecuter(copypasteField, q= 1, t= 1)
		host = addr.split(':')[0] if ':' in addr else ''
		port = addr.split(':')[1] if ':' in addr else ''
		pm.textField(tcHost_txt, e= 1, tx= host)
		pm.textField(tcPort_txt, e= 1, tx= port)
	pm.button(ps_btn, e= 1, c= pasteAddr)

	def saveTarget(*args):
		pm.textScrollList(trg_sls, e= 1, ra= 1)
		pm.textScrollList(trg_sls, e= 1, append= [str(i.name()) for i in pm.ls(sl= 1)])
	pm.button(svt_btn, e= 1, c= saveTarget)

	def addTarget(*args):
		ai = pm.textScrollList(trg_sls, q= 1, ai= 1)
		ai.extend([str(i.name()) for i in pm.ls(sl= 1)])
		ai = list(set(ai))
		pm.textScrollList(trg_sls, e= 1, ra= 1)
		pm.textScrollList(trg_sls, e= 1, append= ai)
	pm.button(adt_btn, e= 1, c= addTarget)

	def rmvTarget(*args):
		sel = pm.textScrollList(trg_sls, q= 1, si= 1)
		pm.textScrollList(trg_sls, e= 1, ri= sel)
	pm.button(rmt_btn, e= 1, c= rmvTarget)

	def _setConn():
		mode = 'LAN' if mode_mqsb.isChecked() else 'local'
		host = pm.textField(tcHost_txt, q= 1, tx= 1)
		port = pm.textField(tcPort_txt, q= 1, tx= 1)
		if port and ((mode == 'LAN' and host) or mode == 'local'):
			beam.setCoord(int(port), host= host)
			return True

	def checkConn(*args):
		if _setConn():
			beam.cmdSend('cmds.warning("[AniRemap] Connection Test Success.")', silent= 1)
	pm.button(ch_btn, e= 1, c= checkConn)
	
	def execRemap(*args):
		remapType = pm.optionMenu(match_mnu, q= 1, v= 1)
		tirm = tirm_mqsb.isChecked()
		sel_src = not hSrc_mqsb.isChecked()
		sel_dis = not hTrg_mqsb.isChecked()
		scale = pm.floatField(scale_flt, q= 1, v= 1)
		mirror = [None, 'X', 'Z', 'Y'][pm.radioButtonGrp('mirror_radioBtnGrp' , q= 1, sl= 1) - 1]
		if maya_mqsb.isChecked():
			if _setConn:
				mr.remoteRemap(beam, remapType, tirm, sel_src, sel_dis, scale, mirror)
		else:
			dis = [str(i) for i in pm.textScrollList(trg_sls, q= 1, ai= 1)]
			mr.localRemap(dis, remapType, tirm, sel_src, sel_dis, scale, mirror)
	pm.button(remap_btn, e= 1, c= execRemap)

	def dockCloseCmd(*args):
		mark.portClose(0)
	pm.dockControl(windowName, area= 'right', content= main_window, allowedArea= ['right', 'left'], \
		vis= 1, s= 0, ret= 0, w= dockWidth, vcc= dockCloseCmd)
예제 #45
0
 def show(self, *args, **kwargs):
   ''' '''
   if self.dockable:
     mainDock = pm.dockControl(self.dockName, label=self.windowName, area=self.startArea, content=self.mainWindow, allowedArea=self.allowedAreas, floating=self.floating, w=self.width, h=self.height)
   else:
     self.mainWindow.show()
예제 #46
0
 def closeUI(self, *args):
     if self.docker!=None:
         if pm.dockControl(self.docker,q=True,ex=True):
             pm.deleteUI(self.docker)
     else:
         self.window.delete()
예제 #47
0
 def raise_(self):
     if self.dockable():
         if self._Pre2017:
             return pm.dockControl(self.WindowID, edit=True, r=True)
         return pm.workspaceControl(self.WindowID, edit=True, restore=True)
     return super(MayaWindow, self).raise_()
예제 #48
0
    def show(cls, self, *args, **kwargs):
        """Show the window.
        It can be as a docked or floating workspaceControl, or just a normal Qt window.

        If the window is just hidden, this should bring back into focus.
        Not tested yet however.
        """
        if self is not cls:
            # Case where window is already initialised
            if self.dockable():
                if MAYA_VERSION < 2017:
                    return pm.dockControl(self.WindowID, edit=True, visible=True)
                result = pm.workspaceControl(self.WindowID, edit=True, visible=True)
                self.parent().setAttribute(QtCore.Qt.WA_DeleteOnClose)
                return result
            return super(MayaWindow, self).show()

        # Close down any instances of the window
        # If a dialog was opened, then the reference will no longer exist
        try:
            cls.clearWindowInstance(cls.WindowID)
        except AttributeError:
            settings = {}
        else:
            settings = getWindowSettings(cls.WindowID)

        # Open a dialog window that will force control
        if not self._Pre2017 and getattr(cls, 'ForceDialog', False):
            cls.WindowDockable = False
            title = getattr(cls, 'WindowName', 'New Window')
            try:
                return dialogWrap(cls, title=title, *args, **kwargs)
            finally:
                cls.clearWindowInstance(cls.WindowID)

        # Load settings
        try:
            mayaSettings = settings['maya']
        except KeyError:
            mayaSettings = settings['maya'] = {}

        if hasattr(cls, 'WindowDockable'):
            docked = cls.WindowDockable
        else:
            try:
                docked = settings['maya']['docked']
            except KeyError:
                try:
                    docked = cls.WindowDefaults['docked']
                except (AttributeError, KeyError):
                    docked = True

        # Override docked mode in case of mayabatch
        batchOverride = False
        if docked and MAYA_BATCH:
            docked = cls.WindowDockable = False
            batchOverride = True

        # Return new class instance and show window
        if docked and not batchOverride:
            if hasattr(cls, 'WindowDocked'):
                floating = not cls.WindowDocked
            else:
                try:
                    floating = settings['maya']['dock']['floating']
                except KeyError:
                    try:
                        floating = cls.WindowDefaults['floating']
                    except (AttributeError, KeyError):
                        floating = False
            if floating:
                dock = False
            else:
                try:
                    if self._Pre2017:
                        dock = settings['maya']['dock'].get('area', True)
                    else:
                        dock = settings['maya']['dock'].get('control', True)
                except KeyError:
                    dock = True
            if self._Pre2017:
                return dockControlWrap(cls, dock, resetFloating=True, *args, **kwargs)
            return workspaceControlWrap(cls, dock, resetFloating=True, *args, **kwargs)

        win = super(MayaWindow, cls).show(*args, **kwargs)
        if batchOverride:
            cls.WindowDockable = True
            win.setDockable(True, override=True)
        return win
예제 #49
0
def dock_panel(engine, shotgun_panel, title, new_panel):
    """
    Docks a Shotgun app panel into a new Maya panel in the active Maya window.

    In Maya 2016 and before, the panel is docked into a new tab of Maya Channel Box dock area.
    In Maya 2017 and after, the panel is docked into a new workspace area in the active Maya workspace.

    :param engine: :class:`MayaEngine` instance running in Maya.
    :param shotgun_panel: Qt widget at the root of the Shotgun app panel.
                          This Qt widget is assumed to be child of Maya main window.
                          Its name can be used in standard Maya commands to reparent it under a Maya panel.
    :param title: Title to give to the new dock tab.
    :param new_panel: True when the Shotgun app panel was just created by the calling function.
                      False when the Shotgun app panel was retrieved from under an existing Maya panel.
    :returns: Name of the newly created Maya panel.
    """

    # The imports are done here rather than at the module level to avoid spurious imports
    # when this module is reloaded in the context of a workspace control UI script.
    import maya.mel as mel

    # Retrieve the Shotgun app panel name.
    shotgun_panel_name = shotgun_panel.objectName()

    # Use the proper Maya panel docking method according to the Maya version.
    if mel.eval("getApplicationVersionAsFloat()") < 2017:

        import maya.utils
        import pymel.core as pm

        # Create a Maya panel name.
        maya_panel_name = "maya_%s" % shotgun_panel_name

        # When the Maya panel already exists, it can be deleted safely since its embedded
        # Shotgun app panel has already been reparented under Maya main window.
        if pm.control(maya_panel_name, query=True, exists=True):
            engine.log_debug("Deleting existing Maya panel %s." % maya_panel_name)
            pm.deleteUI(maya_panel_name)

        # Create a new Maya window.
        maya_window = pm.window()
        engine.log_debug("Created Maya window %s." % maya_window)

        # Add a layout to the Maya window.
        maya_layout = pm.formLayout(parent=maya_window)
        engine.log_debug("Created Maya layout %s." % maya_layout)

        # Reparent the Shotgun app panel under the Maya window layout.
        engine.log_debug("Reparenting Shotgun app panel %s under Maya layout %s." % (shotgun_panel_name, maya_layout))
        pm.control(shotgun_panel_name, edit=True, parent=maya_layout)

        # Keep the Shotgun app panel sides aligned with the Maya window layout sides.
        pm.formLayout(maya_layout,
                      edit=True,
                      attachForm=[(shotgun_panel_name, 'top', 1),
                                  (shotgun_panel_name, 'left', 1),
                                  (shotgun_panel_name, 'bottom', 1),
                                  (shotgun_panel_name, 'right', 1)]
        )

        # Dock the Maya window into a new tab of Maya Channel Box dock area.
        engine.log_debug("Creating Maya panel %s." % maya_panel_name)
        pm.dockControl(maya_panel_name, area="right", content=maya_window, label=title)

        # Since Maya does not give us any hints when a panel is being closed,
        # install an event filter on Maya dock control to monitor its close event
        # in order to gracefully close and delete the Shotgun app panel widget.
        # Some obscure issues relating to UI refresh are also resolved by the event filter.
        panel_util.install_event_filter_by_name(maya_panel_name, shotgun_panel_name)

        # Once Maya will have completed its UI update and be idle,
        # raise (with "r=True") the new dock tab to the top.
        maya.utils.executeDeferred("import maya.cmds as cmds\n" \
                                   "cmds.dockControl('%s', edit=True, r=True)" % maya_panel_name)

    else:  # Maya 2017 and later

        import maya.cmds as cmds

        # Create a Maya panel name.
        maya_panel_name = "maya_%s" % shotgun_panel_name

        # When the current Maya workspace contains our Maya panel workspace control,
        # embed the Shotgun app panel into this workspace control.
        # This can happen when the engine has just been started and the Shotgun app panel is
        # displayed for the first time around, or when the user reinvokes a displayed panel.
        if cmds.workspaceControl(maya_panel_name, exists=True) and \
           cmds.workspaceControl(maya_panel_name, query=True, visible=True):

            engine.log_debug("Restoring Maya workspace panel %s." % maya_panel_name)

            # Set the Maya default parent to be our Maya panel workspace control.
            cmds.setParent(maya_panel_name)

            # Embed the Shotgun app panel into the Maya panel workspace control.
            build_workspace_control_ui(shotgun_panel_name)

            return maya_panel_name

        # Retrieve the Channel Box dock area, with error reporting turned off.
        # This MEL function is declared in Maya startup script file UIComponents.mel.
        # It returns an empty string when a dock area cannot be found, but Maya will
        # retrieve the Channel Box dock area even when it is not shown in the current workspace.
        dock_area = mel.eval('getUIComponentDockControl("Channel Box / Layer Editor", false)')
        engine.log_debug("Retrieved Maya dock area %s." % dock_area)

        # This UI script will be called to build the UI of the new dock tab.
        # It will embed the Shotgun app panel into a Maya workspace control.
        # Since Maya 2017 expects this script to be passed in as a string,
        # not as a function pointer, it must retrieve the current module in order
        # to call function build_workspace_control_ui() that actually builds the UI.
        # Note that this script will be saved automatically with the workspace control state
        # in the Maya layout preference file when the user quits Maya, and will be executed
        # automatically when Maya is restarted later by the user.
        ui_script = "import sys\n" \
                    "import maya.api.OpenMaya\n" \
                    "import maya.utils\n" \
                    "for m in sys.modules:\n" \
                    "    if 'tk_maya.panel_generation' in m:\n" \
                    "        try:\n" \
                    "            sys.modules[m].build_workspace_control_ui('%(panel_name)s')\n" \
                    "        except Exception, e:\n" \
                    "            msg = 'Shotgun: Cannot restore %(panel_name)s: %%s' %% e\n" \
                    "            fct = maya.api.OpenMaya.MGlobal.displayError\n" \
                    "            maya.utils.executeInMainThreadWithResult(fct, msg)\n" \
                    "        break\n" \
                    "else:\n" \
                    "    msg = 'Shotgun: Cannot restore %(panel_name)s: Shotgun is not currently running'\n" \
                    "    fct = maya.api.OpenMaya.MGlobal.displayError\n" \
                    "    maya.utils.executeInMainThreadWithResult(fct, msg)\n" \
                    % {"panel_name": shotgun_panel_name}

        # Dock the Shotgun app panel into a new workspace control in the active Maya workspace.
        engine.log_debug("Creating Maya workspace panel %s." % maya_panel_name)

        kwargs = {"uiScript": ui_script,
                  "retain": False,  # delete the dock tab when it is closed
                  "label": title,
                  "r": True}  # raise at the top of its workspace area

        # When we are in a Maya workspace where the Channel Box dock area can be found,
        # dock the Shotgun app panel into a new tab of this Channel Box dock area
        # since the user was used to this behaviour in previous versions of Maya.
        # When we are in a Maya workspace where the Channel Box dock area can not be found,
        # let Maya embed the Shotgun app panel into a floating workspace control window.
        kwargs["tabToControl"] = (dock_area, -1)  # -1 to append a new tab

        cmds.workspaceControl(maya_panel_name, **kwargs)

    return maya_panel_name
예제 #50
0
 def show_panel(self, panel_id, title, bundle, widget_class, *args, **kwargs):
     """
     Docks an app widget in a maya panel. 
     
     :param panel_id: Unique identifier for the panel, as obtained by register_panel().
     :param title: The title of the panel
     :param bundle: The app, engine or framework object that is associated with this window
     :param widget_class: The class of the UI to be constructed. This must derive from QWidget.
     
     Additional parameters specified will be passed through to the widget_class constructor.
     """
     from tank.platform.qt import QtCore, QtGui
     
     tk_maya = self.import_module("tk_maya")
     
     self.log_debug("Begin showing panel %s" % panel_id)                                    
     
     # The general approach below is as follows:
     #
     # 1. First create our qt tk app widget using QT.
     #    parent it to the maya main window to give it
     #    a well established parent. If the widget already
     #    exists, don't create it again, just retrieve its 
     #    handle
     #
     # 2. Now create a native maya window and layout and 
     #    attach our QT control to this. For this, we use
     #    the QT objectname property to do the bind. Note that
     #    the window won't show in the UI, this is all just 
     #    setting up the hiearchy.
     #    
     # 3. If a panel already exists, delete it. The panel 
     #    no longer has the tk widget inside it, since that is
     #    parented to the window that was just created
     #
     # 4. Create a new panel using the dockControl command and
     #    pass our maya window in as the object to dock.
     #
     # 5. Lastly, since our widgets won't get notified about 
     #    when the parent dock is closed (and sometimes when it
     #    needs redrawing), attach some QT event watchers to it
     #
     #
     # Note: It is possible that the close event and some of the 
     #       refresh doesn't propagate down to the widget because
     #       of a misaligned parenting: The tk widget exists inside
     #       the pane layout but is still parented to the main 
     #       maya window. It's possible that by setting up the parenting
     #       explicitly, the missing signals we have to compensate for 
     #       may start to work. I tried a bunch of stuff but couldn't get
     #       it to work and instead resorted to the event watcher setup. 
     
     # make a unique id for the app widget based off of the panel id
     widget_id = "wdgt_%s" % panel_id  
     
     # create a maya window and layout
     window = pm.window()
     self.log_debug("Created window: %s" % window)
     maya_layout = pm.formLayout(parent=window)
     self.log_debug("Created layout %s" % maya_layout)
     
     if pm.control(widget_id, query=1, exists=1):
         self.log_debug("Toolkit widget already exists. Reparenting it...")
         # find the widget for later use
         for widget in QtGui.QApplication.allWidgets():
             if widget.objectName() == widget_id:
                 widget_instance = widget
                 break
         
     else:
         self.log_debug("Toolkit widget does not exist - creating it...")
         # parent the UI to the main maya window
         parent = self._get_dialog_parent()            
         widget_instance = widget_class(*args, **kwargs)
         widget_instance.setParent(parent)
         # set its name - this means that it can also be found via the maya API
         widget_instance.setObjectName(widget_id)
         self.log_debug("Created %s (Object Name '%s')" % (widget_instance, widget_id))
         # apply external stylesheet
         self._apply_external_styleshet(bundle, widget_instance)
                   
     
     # now reparent the widget instance to the layout
     # we can now refer to the QT widget via the widget name
     self.log_debug("Parenting widget %s to temporary window %s..." % (widget_id, maya_layout))
     pm.control(widget_id, edit=True, parent=maya_layout)
     
     # now attach our widget in all four corners to the maya layout so that it fills 
     # the entire panel space
     pm.formLayout(maya_layout, 
                   edit=True, 
                   attachForm=[(widget_id, 'top', 1), 
                               (widget_id, 'left', 1), 
                               (widget_id, 'bottom', 1), 
                               (widget_id, 'right', 1)] )
     
     if pm.control(panel_id, query=1, exists=1):
         # exists already - delete it
         self.log_debug("Panel exists. Deleting it.")
         pm.deleteUI(panel_id)
                 
     # lastly, move the maya window into a dock
     pm.dockControl(panel_id, area="right", content=window, label=title)
     self.log_debug("Created panel %s" % panel_id)
 
     # just like nuke, maya doesn't give us any hints when a panel is being closed.
     # QT widgets contained within this panel are just unparented and the floating
     # around, taking up memory.
     #
     # the visibleChangeCommand callback offered by the dockControl command
     # doesn't seem to work
     #
     # instead, install a QT event watcher to track when the parent
     # is closed and make sure that the tk widget payload is closed and
     # deallocated at the same time.
     #
     # Also, there are some obscure issues relating to UI refresh. These are also
     # resolved by looking at the stream of event and force triggering refreshes at the 
     # right locations
     #  
     tk_maya.install_callbacks(panel_id, widget_id)
예제 #51
0
파일: gui.py 프로젝트: bohdon/viewGui
 def hideDock(self):
     pm.dockControl(self.dockControl, e=True, vis=False)