Beispiel #1
0
def get_main_window_name():
    return pmc.MelGlobals()['gMainWindow']
def style_maya_shelves():
    """
    Style Maya shelves.
    """

    #Lazy Import
    #----------------------------------------------------
    #PySide
    from PySide import QtGui
    from PySide import QtCore
    from PySide import QtUiTools
    import shiboken
    import pysideuic
    #maya
    import pymel.core as pm
    #----------------------------------------------------


        
    #Tabwidgets (Shelves)
    #----------------------------------------------------

    #wdgt_toplevel_shelf_name
    wdgt_toplevel_shelf_name = pm.MelGlobals()['gShelfTopLevel']

    #wdgt_toplevel_shelf
    wdgt_toplevel_shelf = get_maya_toplevel_shelf_widget(wdgt_toplevel_shelf_name)

    #shelf not found
    if not(wdgt_toplevel_shelf):
        print('Shelf {0} not found. Not customizing, returning.'.format(wdgt_toplevel_shelf_name))
        return None


    #tab_wdgt_list
    tab_wdgt_list = [tab_wdgt for tab_wdgt in wdgt_toplevel_shelf.findChildren(QtGui.QTabWidget)]
    
    
    


    #Stylesheets
    #----------------------------------------------------

    #ss_shelf
    ss_shelf = " \
\
\
QWidget#%s { background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0.5 rgba(0, 0, 0, 0), stop:1 rgba(255, 255, 255, 255)); }\
\
\
"
    
    #----------------------------------------------------




    #Style
    #----------------------------------------------------
    
    #iterate and style
    for tab_wdgt in tab_wdgt_list:

        #index
        index = tab_wdgt.count()

        #setDocumentMode
        tab_wdgt.setDocumentMode(True)

        #iterate and style page
        for index in range(index):
            
            #wdgt_page
            wdgt_page = tab_wdgt.widget(index)

            #iterate scrollareas
            for wdgt_scrollarea in wdgt_page.findChildren(QtGui.QScrollArea):

                #wdgt_scrollarea_child
                wdgt_scrollarea_child = wdgt_scrollarea.widget()
                
                try:

                    #set_stylesheet
                    wdgt_scrollarea_child.setStyleSheet(ss_shelf%(wdgt_scrollarea_child.objectName()))

                except:
                    pass
Beispiel #3
0
def get_main_window_name():
    """return the main maya window
    """
    w = pmc.MelGlobals()['gMainWindow']
    return w
Beispiel #4
0
import shiboken
import pymel.core as pm
  
def getMayaShelfObj(shelfObj):
    ptr = omUI.MQtUtil.findLayout(shelfObj)
    if ptr is not None:
        return shiboken.wrapInstance(long(ptr), QtGui.QWidget)

def testEvent():
    print "hello world!!"
    
def push():
    pos = QtGui.QCursor.pos()
    Menu.popup(pos) 

shelfParent = pm.MelGlobals()['gShelfTopLevel']

shelfName = "qtTest"
if pm.shelfLayout(shelfName,exists=True) == True:
    shelf       = pm.shelfLayout(shelfName,e=True)
else:
    shelf       = pm.shelfLayout(shelfName,p=shelfParent)

widget      = getMayaShelfObj(shelf.name())

LO          = widget.layout()
Btn         = QtGui.QPushButton("MENU")
 
LO.addWidget(Btn)
 
exitAction = QtGui.QAction('TestAction',Btn,triggered=testEvent)
Beispiel #5
0
    def __init__(self):

        fg_menu_name = 'fg_menu'
        if pm.menu(fg_menu_name, query=True, exists=True):
            pm.deleteUI(fg_menu_name, menu=True)

        with pm.menu(fg_menu_name, tearOff=True, parent=pm.MelGlobals()['gMainWindow'], label='FG-Tools'):
            pm.menuItem(dividerLabel='File', divider=True)
            pm.menuItem(label='Smart Open',
                        image='fileOpen.png',
                        sourceType='mel',
                        command=('int $mods = `getModifiers`;\n'
                                 'if ($mods % 2) { // Shift\n'
                                 '    fgReloadScene;\n'
                                 '} else {\n'
                                 '    fgSmartOpen;\n'
                                 '}'),
                        annotation=('Open File and set Project if possible.\n'
                                    'Shift: Reload the current Scene.'))
            pm.menuItem(label='Save Incremental',
                        sourceType='mel',
                        command='fgSaveIncremental;',
                        annotation='Save a new version of the currently open scene. '
                                   'The last number in the file will be incremented.')
            pm.menuItem(label='Save Snapshot',
                        sourceType='mel',
                        command='fgSaveSnapshot;',
                        annotation='Save a snapshot from the viewport in your current render folder.')

            with pm.subMenuItem(tearOff=True, label='Open Explorer'):
                pm.menuItem(label='Open Scene Folder',
                            sourceType='mel',
                            command='fgOpenSceneFolder;',
                            annotation='Open the folder where the current scene lives in.')
                pm.menuItem(label='Open Render Folder',
                            sourceType='mel',
                            command='fgOpenRenderFolder;',
                            annotation='Open the folder that is defined as "images" in the workspace.')
                pm.menuItem(label='Open Texture Folder',
                            sourceType='mel',
                            command='fgOpenTextureFolder;',
                            annotation='Open the folder that is defined as "Source images" in the workspace.')

            pm.menuItem(dividerLabel='Select', divider=True)
            pm.menuItem(label='Select Triangles',
                        command='fgSelectTriangles;',
                        image='fg-icons_triangles_32.png',
                        sourceType='mel',
                        echoCommand=True,
                        annotation='Select triangles from all polygon objects you selected.')
            pm.menuItem(label='Select N-Gons',
                        image='fg-icons_n-gons_32.png',
                        command='fgSelectNGons;',
                        sourceType='mel',
                        echoCommand=True,
                        annotation='Select n-gons from all polygon objects you selected.')
            pm.menuItem(label='Select Lamina Faces',
                        image='fg-icons_lamina_32.png',
                        command='fgSelectLaminaFaces;',
                        sourceType='mel',
                        echoCommand=True,
                        annotation='Select lamina faces from all polygon objects you selected.')
            pm.menuItem(label='Select Non-Manifold Vertices',
                        imageOverlayLabel='NonMani',
                        command='fgSelectNonManifoldVertices;',
                        sourceType='mel',
                        echoCommand=True,
                        annotation='Select non-manifold vertices from all polygon objects you selected.')
            pm.menuItem(label='Select UV-Seams',
                        imageOverlayLabel='UVSeam',
                        command='fgSelectUVSeams;',
                        sourceType='mel',
                        echoCommand=True,
                        annotation='Select UV-seams from all polygon objects you selected.')
            pm.menuItem(label='Select Hard Edges',
                        imageOverlayLabel='HardE',
                        command='fgSelectHardEdges;',
                        sourceType='mel',
                        echoCommand=True,
                        annotation='Select hard edges in polygon objects you selected.')

            pm.menuItem(dividerLabel='Modeling', divider=True)
            pm.menuItem(label='Spherify',
                        command='fgSpherify;',
                        image='fg_spherify.png',
                        sourceType='mel',
                        echoCommand=True,
                        annotation='Move all selected components to equal distance.')
            pm.menuItem(label='Move Components to X-Axis',
                        command='fgAverageComponents -axis "x";',
                        image='fg_average_selection_x.png',
                        sourceType='mel',
                        echoCommand=True,
                        annotation='Move all selected components so they are aligned on the x-axis.')
            pm.menuItem(label='Move Components to Y-Axis',
                        command='fgAverageComponents -axis "y";',
                        image='fg_average_selection_y.png',
                        sourceType='mel',
                        echoCommand=True,
                        annotation='Move all selected components so they are aligned on the y-axis.')
            pm.menuItem(label='Move Components to Z-Axis',
                        command='fgAverageComponents -axis "z";',
                        image='fg_average_selection_z.png',
                        sourceType='mel',
                        echoCommand=True,
                        annotation='Move all selected components so they are aligned on the z-axis.')
            pm.menuItem(label='Assign Default Shader',
                        command='fgAssignDefaultShaderToSelection;',
                        image='fg_lambert1.png',
                        sourceType='mel',
                        echoCommand=True,
                        annotation='Assign the Default Shader "lambert1" to all selected objects.')
            pm.menuItem(label='Toggle X-Ray',
                        command='fgToggleXRayDisplayOfSelection;',
                        image='fg_x_ray.png',
                        sourceType='mel',
                        echoCommand=True,
                        annotation='Toggle X-Ray display in the viewport on all selected objects.')

            pm.menuItem(dividerLabel='Pivots', divider=True)
            pm.menuItem(label='Copy Pivot',
                        command='fgCopyPivot;',
                        image='fg_copy_pivot.png',
                        sourceType='mel',
                        echoCommand=True,
                        annotation='Copies the pivot of the selected object.')
            pm.menuItem(label='Paste Pivot',
                        command='fgPastePivot;',
                        image='fg_paste_pivot.png',
                        sourceType='mel',
                        echoCommand=True,
                        annotation='Pastes the pivot to all selected objects.')
            pm.menuItem(label='Pivots to WorldCenter',
                        command='fgPivotsToWorldCenter;',
                        image='fg_center_pivot_world.png',
                        sourceType='mel',
                        echoCommand=True,
                        annotation='Moves the pivots of all selected objects to the world-center.')
            pm.menuItem(label='Pivot to Selection',
                        command='fgPivotToSelection;',
                        imageOverlayLabel='selP',
                        sourceType='mel',
                        echoCommand=True,
                        annotation='Moves the pivot to the middle of the selected components.')
            pm.menuItem(label='Pivot to Bottom',
                        command='fgPivotToBottom;',
                        imageOverlayLabel='Pbot',
                        sourceType='mel',
                        echoCommand=True,
                        annotation='Moves the pivot to the center of the combined bounding box. Except the y-axis '
                                   'which will be at the bottom of the bounding box')