Esempio n. 1
0
    def pysideWrapInstance(ptr, base=None):
        '''Utility to convert a point to a Qt Class and produce the same result
        as sip.wrapinstance using shiboken.wrapInstance.

        Note: This is modeled after nathanhorne.com/?p=486. The base arg isn't
        currently used, and defaults to QObject. The way that base arg was used
        seems like it would give a different result than the sip version. It would
        skip the checking for attribute and just use base as base, however the sip
        version will still return QMainWindow even if QObject is passed in.
        '''
        if ptr is None:
            return

        import shiboken
        import PySide.QtCore as qtcore
        import PySide.QtGui as qtgui

        qObj = shiboken.wrapInstance(long(ptr), qtcore.QObject)
        metaObj = qObj.metaObject()
        cls = metaObj.className()
        superCls = metaObj.superClass().className()
        if hasattr(qtgui, cls):
            base = getattr(qtgui, cls)
        elif hasattr(qtgui, superCls):
            base = getattr(qtgui, superCls)
        else:
            base = qtgui.QWidget
        return shiboken.wrapInstance(long(ptr), base)
Esempio n. 2
0
def convert(mguiName):
	"""
	From the name of a Maya UI element of any type to pointer,
	and wrap the pointer into a python QObject
	:param mguiName: Maya UI Name
	:type mguiName: string
	:return: QWidget or subclass instance
	:rtype: QtGui.QWidget

	Thanks to Nathan Horne
	"""
	# Get pointer
	ptr = MQtUtil.findControl(mguiName)
	if ptr is None:
		ptr = MQtUtil.findLayout(mguiName)
	if ptr is None:
		ptr = MQtUtil.findMenuItem(mguiName)
	if ptr is None:
		return None
	# Find corresponding class
	qObj = wrapInstance(long(ptr), QtCore.QObject)
	metaObj = qObj.metaObject()
	cls = metaObj.className()
	superCls = metaObj.superClass().className()
	if hasattr(QtGui, cls):
		base = getattr(QtGui, cls)
	elif hasattr(QtGui, superCls):
		base = getattr(QtGui, superCls)
	else:
		base = QtGui.QWidget

	return wrapInstance(long(ptr), base)
Esempio n. 3
0
def wrapinstance(ptr, base=None):
	"""
	Utility to convert a pointer to a Qt class instance

	:param ptr: Pointer to QObject in memory
	:type ptr: long or Swig instance
	:param base: (Optional) Base class to wrap with (Defaults to QObject, which should handle anything)
	:type base: QtGui.QWidget
	:return: QWidget or subclass instance
	:rtype: QtGui.QWidget
	"""
	if ptr is None:
		return None
	ptr = long(ptr)  #Ensure type
	if qt_lib == 'pyqt':
		base = QtCore.QObject
		return sip.wrapinstance(long(ptr), base)
	elif qt_lib == 'pyside':
		#Pyside makes this a pain for us, since unlike Pyqt it does not return the "best" matching class automatically
		if base is None:
			qObj = shiboken.wrapInstance(long(ptr), QtCore.QObject)
			metaObj = qObj.metaObject()
			cls = metaObj.className()
			superCls = metaObj.superClass().className()
			if hasattr(QtGui, cls):
				base = getattr(QtGui, cls)
			elif hasattr(QtGui, superCls):
				base = getattr(QtGui, superCls)
			else:
				base = QtGui.QWidget
		return shiboken.wrapInstance(long(ptr), base)
Esempio n. 4
0
    def initializeCallback(self):

        #get current model panel
        self.currentModelPanel = cmds.getPanel(wf = 1)
        if "modelPanel" not in self.currentModelPanel:
            self.currentModelPanel = cmds.getPanel(vis = 1)
            for i in self.currentModelPanel:
                if "modelPanel" in i:
                    self.currentModelPanel = i


        #try removing old callbacks from memory
        try:
            OpenMayaUI.MUiMessage.removeCallback(self.callBack)
        except:
            pass

        #create a callback that is registered after a frame is drawn with a 3D content but before 2D content
        self.callback = OpenMayaUI.MUiMessage.add3dViewPostRenderMsgCallback(self.currentModelPanel, self.update)
        self.view3D.refresh(True, True)

        #create QT maya window event filter
        main_window_ptr = OpenMayaUI.MQtUtil.mainWindow()
        self.qt_Maya_Window = wrapInstance(long(main_window_ptr), QtCore.QObject)
        self.qt_Maya_Window.installEventFilter(self.userKeyboardEvents) 

        #create viewport event filter
        active_view_ptr = self.view3D.widget()
        self.qt_Active_View = wrapInstance(long(active_view_ptr), QtCore.QObject)
        self.qt_Active_View.installEventFilter(self.userMouseEvents)

        cmds.inViewMessage( amg='<hl>Tool:</hl> Use <hl>"Esc"</hl> to cancel the tool', pos='botLeft', fade=True )

        print "Initialized..."
Esempio n. 5
0
def wrapinstance(ptr, base=None):
    """Convert a pointer to a Qt class instance.
 
    :param int ptr: Pointer to QObject in memory.
    :param class base: Base class to wrap with.
    :returns: QWidget or subclass instance

    """

    if ptr is None:
        return None
    ptr = long(ptr)

    if sip is not None:
        return sip.wrapinstance(ptr, base or QtCore.QObject)

    if shiboken is not None:
        if base is None:

            # Do a generic wrap so that we can detect what type the object
            # actually is.
            q_obj = shiboken.wrapInstance(ptr, QtCore.QObject)
            meta_obj = q_obj.metaObject()
            class_name = meta_obj.className()
            super_name = meta_obj.superClass().className()

            base = (getattr(QtGui, class_name, None) or
                    getattr(QtGui, super_name, None) or
                    QtGui.QWidget)

        return shiboken.wrapInstance(ptr, base)
Esempio n. 6
0
def wrapinstance(ptr, base = None):
    """Utility to convert a pointer to a Qt class instance (PySide/PyQt compatible)
    @param ptr: Pointer to QObject in memory
    @type ptr: long or Swig instance
    @param base: (Optional) Base class to wrap with (Defaults to QObject,
                 which should handle anything)
    @type base: QtGui.QWidget
    @return: QWidget or subclass instance
    @rtype: QtGui.QWidget

    """
    if ptr is None:
        return None
    ptr = long(ptr)
    if base is None:
        qObj = shiboken.wrapInstance(long(ptr), QtCore.QObject)
        metaObj = qObj.metaObject()
        cls = metaObj.className()
        superCls = metaObj.superClass().className()
        if hasattr(QtGui, cls):
            base = getattr(QtGui, cls)
        elif hasattr(QtGui, superCls):
            base = getattr(QtGui, superCls)
        else:
            base = QtGui.QWidget
    return shiboken.wrapInstance(long(ptr), base)
def create(docked=True):
    global dialog

    if dialog is None:
        dialog = LightIt()

    # docking window if statment    
    if docked is True:
        ptr = mui.MQtUtil.mainWindow()
        main_window = shiboken.wrapInstance(long(ptr), qg.QWidget)

        dialog.setParent( main_window )
        size = dialog.size()
        #return proper full name
        name = mui.MQtUtil.fullName(long(shiboken.getCppPointer(dialog)[0]))
        dock = mc.dockControl(
            allowedArea =['right', 'left'],
            area        = 'left',
            floating    = True,
            content     = name,
            width       = size.width(),
            height      = size.height(),
            label       = 'Lighting Tools v1.04')

        # Convert to Dock widget
        widget      = mui.MQtUtil.findControl(dock)
        dock_widget = shiboken.wrapInstance(long(widget), qc.QObject)
        dialog.connectDockWidget( dock, dock_widget )

    else:
        dialog.show()
Esempio n. 8
0
def wrap_instance(ptr, base=None):
	'''
	Utility to convert a pointer to a Qt class instance (PySide/PyQt compatible)

	:param ptr: Pointer to QObject in memory
	:type ptr: long or Swig instance
	:param base: (Optional) Base class to wrap with (Defaults to QObject,
	             which should handle anything)
	:type base: QtGui.QWidget
	:return: QWidget or subclass instance
	:rtype: QtGui.QWidget
	'''
	if ptr is None:
		return None
	ptr = long(ptr) #Ensure type
	if globals().has_key('shiboken'):
		if base is None:
			qObj = shiboken.wrapInstance(long(ptr), QtCore.QObject)
			metaObj = qObj.metaObject()
			cls = metaObj.className()
			superCls = metaObj.superClass().className()
			if hasattr(QtGui, cls):
				base = getattr(QtGui, cls)
			elif hasattr(QtGui, superCls):
				base = getattr(QtGui, superCls)
			else:
				base = QtGui.QWidget
		return shiboken.wrapInstance(long(ptr), base)
	elif globals().has_key('sip'):
		base = QtCore.QObject
		return sip.wrapinstance(long(ptr), base)
	else:
		return None
Esempio n. 9
0
def wrapinstance( ptr, base = None ):
   """
   Nathan Horne
   """
   if ptr is None:
      return None
   
   ptr = long( ptr ) #Ensure type
   if globals().has_key( 'shiboken' ):
      if base is None:
         qObj = shiboken.wrapInstance( long( ptr ), QtCore.QObject )
         metaObj = qObj.metaObject()
         cls = metaObj.className()
         superCls = metaObj.superClass().className()
         if hasattr( QtGui, cls ):
            base = getattr( QtGui, cls )
            
         elif hasattr( QtGui, superCls ):
            base = getattr( QtGui, superCls )
            
         else:
            base = QtGui.QWidget
            
      return shiboken.wrapInstance( long( ptr ), base )
   
   elif globals().has_key( 'sip' ):
      base = QtCore.QObject
      
      return sip.wrapinstance( long( ptr ), base )
   
   else:
      return None
def create(docked=True):
    global tractor_submit_dialog
    logging.info("create dialog tractor_submit_dialog")
    if tractor_submit_dialog is None:
        tractor_submit_dialog = TractorSubmit()

    if docked is True:
        ptr = mui.MQtUtil.mainWindow()
        main_window = shiboken.wrapInstance(long(ptr), qg.QWidget)

        tractor_submit_dialog.setParent(main_window)
        size = tractor_submit_dialog.size()

        name = mui.MQtUtil.fullName(long(shiboken.getCppPointer(tractor_submit_dialog)[0]))
        dock = mc.dockControl(
            allowedArea=["right", "left"],
            area="right",
            floating=False,
            content=name,
            width=size.width(),
            height=size.height(),
            label="UTS_FARM_SUBMIT",
        )

        widget = mui.MQtUtil.findControl(dock)
        dock_widget = shiboken.wrapInstance(long(widget), qg.QWidget)
        tractor_submit_dialog.connectDockWidget(dock, dock_widget)
    else:
        tractor_submit_dialog.show()
Esempio n. 11
0
 def wrapinstance(ptr):
     """Converts a pointer (int or long) into the concrete PyQt / PySide object it represents """
     ptr = long(ptr)
     qobj = shiboken.wrapInstance(ptr, QtCore.QObject)
     metaobj = qobj.metaObject()
     realcls = None
     while(realcls is None):
         realcls = _getcls(metaobj.className())
         metaobj = metaobj.superClass()
     return shiboken.wrapInstance(ptr,realcls)
Esempio n. 12
0
def setupMannequinUI():
    """Sets up the side panel UI for the Mannequin plugin."""

    currentContext = cmds.currentCtx()
    influenceObjectsStr = cmds.mannequinContext(currentContext,
                                                q=True,
                                                io=True)
    ioTokens = influenceObjectsStr.split(" ")
    ioDagPaths = ioTokens[::2]
    ioAvailableStyles = ioTokens[1::2]

    mannequinDockPtr = MQtUtil.findLayout("mannequinPaletteDock")
    mannequinDock = wrapInstance(long(mannequinDockPtr), QWidget)
    mannequinDock.setMinimumWidth(300)

    mannequinLayoutPtr = MQtUtil.findLayout("mannequinPaletteLayout")
    mannequinLayout = wrapInstance(long(mannequinLayoutPtr), QWidget)

    mannequinSearchPtr = MQtUtil.findControl("mannequinSearchField")
    mannequinSearch = wrapInstance(long(mannequinSearchPtr), QLineEdit)

    uiFile = QFile(os.path.join(os.path.dirname(__file__), "mannequin.ui"))
    uiFile.open(QFile.ReadOnly)
    gui = mannequinToolPanel.loader.load(uiFile, parentWidget=mannequinLayout)
    uiFile.close()

    selList = om.MSelectionList()
    for obj in ioDagPaths:
        selList.add(obj)

    joints = []
    for i in range(selList.length()):
        dagPath = selList.getDagPath(i)
        dependNode = selList.getDependNode(i)
        styles = ioAvailableStyles[i]

        joints.append(JointInfo(dagPath, dependNode, styles))

    # Alphabetize joints by full DAG path; should sort slightly better.
    joints = sorted(joints, key=lambda j: j.dagPath.fullPathName())

    prefixTrim = commonPrefix(joints)
    mannequinToolPanel.reset(mannequinLayout,
                             gui,
                             mannequinSearch,
                             prefixTrim)

    jointDisplays = organizeJoints(joints)
    for jointDisplay in jointDisplays:
        mannequinToolPanel.layoutJointGroup(jointDisplay)
    mannequinToolPanel.finishLayout()
Esempio n. 13
0
def wrap_instance(pointer, base_class=None):
    ptr = long(pointer)
    qObj = shiboken.wrapInstance(long(ptr), QtCore.QObject)
    metaObj = qObj.metaObject()
    cls = metaObj.className()
    superCls = metaObj.superClass().className()

    if hasattr(QtGui, cls):
        base = getattr(QtGui, cls)
    if hasattr(QtGui, superCls):
        base = getattr(QtGui, superCls)

    base = QtGui.QWidget if not base_class else base_class
    return shiboken.wrapInstance(long(ptr), base)
Esempio n. 14
0
 def wrapInstance(ptr):
     if "PyQt4" in QtGui.__name__:
         import sip
         return sip.wrapinstance(long(ptr), QtCore.QObject)
     elif "PySide" in QtGui.__name__:
         import shiboken
         return shiboken.wrapInstance(long(ptr), QtGui.QWidget)
Esempio n. 15
0
    def centre(self):
        # panelPtr = omui.MQtUtil.findControl('toolBar2')
        panelPtr = omui.MQtUtil.findControl("modelPanel1")

        if panelPtr == None:
            """
            Center the main window on the screen. This implemention will handle the window
            being resized or the screen resolution changing.
            """
            # Get the current screens' dimensions...
            screen = QtGui.QDesktopWidget().screenGeometry()
            # ... and get this windows' dimensions
            mysize = self.geometry()
            # The horizontal position is calulated as screenwidth - windowwidth /2
            hpos = (screen.width() - mysize.width()) / 2
            # And vertical position the same, but with the height dimensions
            vpos = (screen.height() - mysize.height()) / 2
            # And the move call repositions the window
            self.move(hpos + 300, vpos - 100)
        else:
            panel = wrapInstance(long(panelPtr), QtGui.QWidget)
            position = panel.mapToGlobal(panel.pos())
            # self.move(position.x(), position.y() + (panel.geometry().height() / 2 - self.geometry().height() / 2) + 5)
            self.move(position.x(), position.y())

            self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
def loadUI(uiName):
	# object to load ui files
	loader = QUiLoader()

	fileDir = ""

	XMLbuffer = None

	for p in pythonPath:
		fname = p + '/' + uiName
		uiFile = QFile(fname)

		if uiFile.exists():
			fileDir = p
			uiFile.open(QFile.ReadOnly)
			XMLbuffer = QByteArray(uiFile.readAll())
			uiFile.close()
			print 'Found UI file path ' + fileDir
			break
		else:
			print 'UI file' + uiName + ' not found ( ' + p + ' )'

	mayaWinPtr	= omui.MQtUtil.mainWindow()
	mayaWin		= wrapInstance(long(mayaWinPtr), QWidget)
	fixXML(XMLbuffer, p)
	qbuff = QBuffer()
	qbuff.open(QBuffer.ReadOnly|QBuffer.WriteOnly)
	qbuff.write(XMLbuffer)
	qbuff.seek(0)
	mayaPtr = getMayaWin()
	ui = loader.load(qbuff,parentWidget =mayaWin)
	#ui.setWindowFlags(Qt.Window) #Window stays on top
	#ui.setWindowFlags(Qt.WindowStaysOnTopHint) #Window stays on top
	ui.path = p
	return ui
Esempio n. 17
0
def wrap_instance(ptr, base):
    '''Return QtGui object instance based on pointer address
    '''
    if globals().has_key('sip'):
        return sip.wrapinstance(long(ptr), QtCore.QObject)
    elif globals().has_key('shiboken'):
        return shiboken.wrapInstance(long(ptr), base)
Esempio n. 18
0
 def __init__(self):
     QtGui. QDialog.__init__(
         self, wrapInstance(
            long(OpenMayaUI.MQtUtil.mainWindow()), QtGui.QDialog
         )
     )
     self._new_init()
Esempio n. 19
0
def get_maya_window():
    """ Get the maya main window as a QMainWindow instance

    :return: Maya main window address
    """
    ptr = OpenMayaUI.MQtUtil.mainWindow()
    return wrapInstance(long(ptr), QMainWindow)
Esempio n. 20
0
    def channelBoxRight(self):

        toggle = self.channelBoxRight_pushButton.isChecked()

        if toggle:

            #toggling left channelbox
            leftToggle = self.channelBoxLeft_pushButton.isChecked()
            self.channelBoxLeft_pushButton.setChecked(False)

            if leftToggle:
                self.channelBoxLeft_widget.setParent(None)

            #creating Right channelbox
            ptr = omui.MQtUtil.findControl(cmds.channelBox())
            self.channelBoxRight_widget = wrapInstance(long(ptr),
                                                      QtGui.QWidget)

            layout = self.channelBoxRight_horizontalLayout
            layout.addWidget(self.channelBoxRight_widget)

            self.resize(400, 0)

            self.updateGeometry()
        else:

            self.channelBoxRight_widget.setParent(None)
Esempio n. 21
0
    def __init__(self, parent = None):
        # Delete any previous instances that is detected. Do this before parenting self to main window!
        self.deleteInstances()

        super(self.__class__, self).__init__(parent = parent)
        
        mayaMainWindowPtr = OpenMayaUI.MQtUtil.mainWindow() 
        self.mayaMainWindow = wrapInstance(long(mayaMainWindowPtr), QtGui.QMainWindow)
        
        self.setObjectName(self.__class__.toolName) # Make this unique enough if using it to clear previous instance!

        # Setup window's properties
        self.setWindowFlags(QtCore.Qt.Window)
        self.setWindowTitle('Hand Rigger Script')
        self.setFixedSize(300, 100)

        # Create a button and stuff it in a layout
        label = QtGui.QLabel("Select two hands (right and left) and run script: ", parent=self)
        label.setAlignment(QtCore.Qt.AlignRight)
        label.setGeometry(0, 15, 280, 20)
        
        self.myButton = QtGui.QPushButton('Run')
        self.mainLayout = QtGui.QVBoxLayout()
        self.mainLayout.addWidget(self.myButton)
        self.setLayout(self.mainLayout)
        self.myButton.clicked.connect(self.buttonPush)
Esempio n. 22
0
def shibokenGetMayaMainWindow():
    mayaMainWindowPtr = apiUI.MQtUtil.mainWindow()
    if mayaMainWindowPtr:
        mayaMainWindow = shiboken.wrapInstance(long(mayaMainWindowPtr), QtGui.QWidget)
        return mayaMainWindow
    else:
        return None
Esempio n. 23
0
    def __init__(self):

        # Sanity check : Plugin
        if not Method.load_plugin():
            QtGui.QMessageBox.information(
                None, "Sol", "Sol's {} plugin is not loaded.\n"
                "UI could not be started.".format(Vars.PLUGIN_NAME)
            )
            return

        # Sanity check : Viewport Renderer
        if not Dialogs.ViewportWarning.check():
            return

        # Single UI
        if pmc.windows.window(Vars.WINDOW_NAME, exists=True):
            pmc.windows.deleteUI(Vars.WINDOW_NAME)

        # QWidget init
        super(SolControlUI, self).__init__(
            shiboken.wrapInstance(long(MQtUtil.mainWindow()), QtGui.QWidget)
        )

        self._init_vars()
        self._init_ui()
        self._init_toolbar()
        self.reload_ui()
Esempio n. 24
0
def getMayaWindow():
    """
    Return the pointer to maya window
    """
    OpenMayaUI.MQtUtil.mainWindow()
    ptr = OpenMayaUI.MQtUtil.mainWindow()
    return shiboken.wrapInstance(long(ptr), QtGui.QWidget)
Esempio n. 25
0
def BT_GetMayaWindow():
    ptr = apiUI.MQtUtil.mainWindow()
    if ptr is not None:
        if BT_MayaVersionNumber < 2014:
            return wrapinstance(long(ptr), QtCore.QObject)
        else:
            return wrapInstance(long(ptr), QtGui.QWidget)
Esempio n. 26
0
    def window_close_all_pyside(cls):
        
        MAYA_WINDOW = wrapInstance(long(MQtUtil.mainWindow()), QtCore.QObject)

        #   For QMainWindow
        if MAYA_WINDOW.findChildren(QtGui.QMainWindow):
            for children in MAYA_WINDOW.findChildren(QtGui.QMainWindow):
                children.close()
Esempio n. 27
0
def get_maya_window():
    """
    Get the main Maya window as a QtGui.QMainWindow instance
    @return: QtGui.QMainWindow instance of the Maya windows
    """
    main_window_ptr = omui.MQtUtil.mainWindow()
    if main_window_ptr is not None:
        return shiboken.wrapInstance(long(main_window_ptr), QtGui.QMainWindow)
Esempio n. 28
0
def maya_main_window():
    """
    Get the main Maya window as a QtGui.QMainWindow instance
    @return: QtGui.QMainWindow instance of the top level Maya windows
    """
    ptr = omu.MQtUtil.mainWindow()
    if ptr is not None:
        return shiboken.wrapInstance(long(ptr), QtGui.QMainWindow)
Esempio n. 29
0
def findWindow(sWindowName):

    ptr = omui.MQtUtil.findWindow(sWindowName)
    if not ptr:
        return None

    window = wrapInstance(long(ptr), QWidget)
    return window
Esempio n. 30
0
def getMayaWindow():
    """
    Get the main Maya window as a QtGui.QMainWindow instance
    @return: QtGui.QMainWindow instance of the top level Maya windows
    """
    ptr = apiUI.MQtUtil.mainWindow()
    if ptr is not None:
        return wrapInstance(long(ptr), QtGui.QMainWindow)
Esempio n. 31
0
    def init_timeline(self):
        """Initializes the timeline widget.
        * sets the layout
        * adds a maya timeport to the widget

        """
        self.setLayout(dlayout.DragSupportLayout())
        cmds.window()
        cmds.columnLayout()
        tp = cmds.timePort(bgc=(0.45, 0.45, 0.45), gt=True)
        tp_ptr = OpenMayaUI.MQtUtil.findControl(tp)
        self.timeport = shiboken.wrapInstance(long(tp_ptr), QtGui.QWidget)
        self.layout().addWidget(self.timeport)
        self.timeport.setSizePolicy(
            QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
                              QtGui.QSizePolicy.Expanding))
        for i in range(self.item.rowCount()):
            key = self.item.child(i).data(QtCore.Qt.DisplayRole)
            self.create_timeline_button(key)
Esempio n. 32
0
def getMainWindow():
    """This function should be overriden"""
    if BoilerDict["Environment"] == "Maya":
        win = omui.MQtUtil_mainWindow()
        ptr = wrapInstance(long(win), QtWidgets.QMainWindow)
        return ptr

    elif BoilerDict["Environment"] == "3dsMax":
        return MaxPlus.GetQMaxWindow()

    elif BoilerDict["Environment"] == "Houdini":
        return hou.qt.mainWindow()

    elif BoilerDict["Environment"] == "Nuke":
        # TODO // Needs a main window getter for nuke
        return None

    else:
        return None
Esempio n. 33
0
def getMayaMainWindow():
    mayaMainWindow = None
    mayaVersion = int(cmds.about(v=True)[:4])
    if 2011 <= mayaVersion < 2014:
        import sip
        from PyQt4.QtGui import QWidget
        mayaMainWindow = sip.wrapinstance(long(mui.MQtUtil.mainWindow()),
                                          QWidget)
    elif 2014 <= mayaVersion < 2017:
        import shiboken
        from PySide.QtGui import QWidget
        mayaMainWindow = shiboken.wrapInstance(long(mui.MQtUtil.mainWindow()),
                                               QWidget)
    elif mayaVersion >= 2017:
        import shiboken2
        from PySide2.QtWidgets import QWidget
        mayaMainWindow = shiboken2.wrapInstance(long(mui.MQtUtil.mainWindow()),
                                                QWidget)
    return mayaMainWindow
Esempio n. 34
0
def dock_window(dialog_class):
    try:
        pm.deleteUI(dialog_class.CONTROL_NAME)
    except:
        pass

    main_control = pm.workspaceControl(dialog_class.CONTROL_NAME, iw=300, ttc=["AttributeEditor", -1], li=False, mw=True, wp='preferred',
                                       label=dialog_class.LABEL_NAME)

    control_widget = OpenMayaUI.MQtUtil.findControl(dialog_class.CONTROL_NAME)

    control_wrap = wrapInstance(long(control_widget), QtWidgets.QWidget)
    control_wrap.setStyleSheet("background-color:#505050;")
    control_wrap.setAttribute(QtCore.Qt.WA_DeleteOnClose)

    win = dialog_class(control_wrap)

    pm.evalDeferred(lambda *args: pm.workspaceControl(main_control, e=True, rs=True))

    return win.run()
Esempio n. 35
0
    def deleteInstances(self):
        mayaMainWindowPtr = OpenMayaUI.MQtUtil.mainWindow()
        mayaMainWindow = wrapInstance(
            long(mayaMainWindowPtr), QtGui.QMainWindow
        )  # Important that it's QMainWindow, and not QWidget/QDialog

        # Go through main window's children to find any previous instances
        for obj in mayaMainWindow.children():
            if type(obj) == maya.app.general.mayaMixin.MayaQDockWidget:
                #if obj.widget().__class__ == self.__class__: # Alternatively we can check with this, but it will fail if we re-evaluate the class
                if obj.widget().objectName(
                ) == self.__class__.toolName:  # Compare object names
                    # If they share the same name then remove it
                    print 'Deleting instance {0}'.format(obj)
                    mayaMainWindow.removeDockWidget(
                        obj
                    )  # This will remove from right-click menu, but won't actually delete it! ( still under mainWindow.children() )
                    # Delete it for good
                    obj.setParent(None)
                    obj.deleteLater()
Esempio n. 36
0
def get_maya_win(module="mayaUI"):
    """
    get a QMainWindow Object of maya main window
    :param module (optional): string "PySide"(default) or "PyQt4"
    :return main_window: QWidget or QMainWindow object
    """
    prt = mui.MQtUtil.mainWindow()
    if module == "PyQt4":
        import sip
        import PyQt4.QtCore as QtCore
        main_window = sip.wrapinstance(long(prt), QtCore.QObject)
    elif module == "PySide":
        import shiboken
        import PySide.QtGui as QtGui
        main_window = shiboken.wrapInstance(long(prt), QtGui.QWidget)
    elif module == "mayaUI":
        main_window = "MayaWindow"
    else:
        raise ValueError('param "module" must be "mayaUI" "PyQt4" or "PySide"')
    return main_window
Esempio n. 37
0
def loadQtWindow(uiFile, windowName):
    '''Auxiliary method that loads .ui files under main Maya window.'''

    # Delete previously loaded UI
    if (cmds.window(windowName, exists=True)):  # @UndefinedVariable
        cmds.deleteUI(windowName)  # @UndefinedVariable

    # Define Maya window
    global mayaMainWindow
    mayaMainWindow = None
    mayaMainWindowPtr = omui.MQtUtil.mainWindow()
    mayaMainWindow = wrapInstance(long(mayaMainWindowPtr), QWidget)

    # Load UI
    loader = QUiLoader()
    file = QFile(uiFile)
    file.open(QFile.ReadOnly)
    windowUI = loader.load(file, parentWidget=mayaMainWindow)
    file.close()

    return windowUI
Esempio n. 38
0
def getDock(name='DAMGtoolBoxIIDock', version=VERSION):
    """
    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
    """
    # Delete any conflicting docks
    deleteDock(name)
    # Create a workspaceControl dock using Maya_tk's UI tools
    if version >= 2017:
        ctrl = cmds.workspaceControl(name, label='Split Joint')
    else:
        ctrl = cmds.dockControl(name, label='Split Joint')
    # Use the OpenMayaUI API to get the actual Qt widget associated with the name
    qtCtrl = omui.MQtUtil_findControl(ctrl)
    # Use wrapInstance to convert it to something Python can understand (QWidget)
    ptr = wrapInstance(long(qtCtrl), QtWidgets.QWidget)
    return ptr
Esempio n. 39
0
    def _makeMayaStandaloneWindow(self):
        '''Make a standalone window, though parented under Maya's mainWindow.
        The parenting under Maya's mainWindow is done so that the QWidget will not
        auto-destroy itself when the instance variable goes out of scope.
        '''
        origParent = self.parent()

        # Parent under the main Maya window
        mainWindowPtr = omui.MQtUtil.mainWindow()
        mainWindow = wrapInstance(long(mainWindowPtr), QMainWindow)
        self.setParent(mainWindow)

        # Make this widget appear as a standalone window even though it is parented
        if isinstance(self, QDockWidget):
            self.setWindowFlags(Qt.Dialog | Qt.FramelessWindowHint)
        else:
            self.setWindowFlags(Qt.Window)

        # Delete the parent QDockWidget if applicable
        if isinstance(origParent, QDockWidget):
            origParent.close()
Esempio n. 40
0
def get_maya_win(module="PySide"):
    """
    get a QMainWindow Object of maya main window
    :param module (optional): string "PySide"(default) or "PyQt4"
    :return main_window: QWidget or QMainWindow object
    """
    prt = mui.MQtUtil.mainWindow()
    if module == "PyQt":
        import sip
        main_window = sip.wrapinstance(long(prt), QObject)
    elif module in ["PySide"]:
        if __binding__ in ["PySide"]:
            import shiboken
        elif __binding__ in ["PySide2"]:
            import shiboken2 as shiboken
        main_window = shiboken.wrapInstance(long(prt), QWidget)
    elif module == "mayaUI":
        main_window = "MayaWindow"
    else:
        raise ValueError('param "module" must be "mayaUI" "PyQt4" or "PySide"')
    return main_window
Esempio n. 41
0
    def __init__(self, parent=None, *args, **kwargs):
        super(MayaQDockWidget, self).__init__(
            parent=parent, *args, **kwargs
        )  # Init all baseclasses (including QWidget) of the main class

        # == Mimic operations performed by Maya internal QmayaDockWidget ==
        self.setAttribute(Qt.WA_MacAlwaysShowToolWindow)

        # WORKAROUND: The mainWindow.handleDockWidgetVisChange may not be present on some PyQt and PySide systems.
        #             Handle case if it fails to connect to the attr.
        mainWindowPtr = omui.MQtUtil.mainWindow()
        mainWindow = wrapInstance(long(mainWindowPtr), QMainWindow)
        try:
            self.visibilityChanged.connect(
                mainWindow.handleDockWidgetVisChange)
        except AttributeError, e:
            # Error connecting visibilityChanged trigger to mainWindow.handleDockWidgetVisChange.
            # Falling back to using MEL command directly.
            mel.eval(
                'evalDeferred("updateEditorToggleCheckboxes()")'
            )  # Currently mainWindow.handleDockWidgetVisChange only makes this updateEditorToggleCheckboxes call
Esempio n. 42
0
    def getMainWindow(cls):
        """
        Returns the main Maya ui as a QWidget
        
        **RETURNS**		QWidget or None
        """

        if cls.MAIN_WIN is not None:
            return cls.MAIN_WIN

        ptr = omui.MQtUtil.mainWindow()

        ##---if ptr is None, that means Maya is in some sort of batch mode (no ui)---##
        if ptr is not None:
            cls.MAIN_WIN = shiboken.wrapInstance(long(ptr), QWidget)
            return cls.MAIN_WIN

        else:
            cls.MAIN_WIN = None

        return None
Esempio n. 43
0
    def __init__(self, k_Treturn):
        #print k_Treturn
        super(k_replyNodes, self).__init__()
        self.setupUi(self)
        self.show()
        Window2 = QtGui.QMainWindow(
            wrapInstance(long(omui.MQtUtil.mainWindow()), QtGui.QWidget))
        Window2.setGeometry(1040, 114, 380, 845)

        self.jsDir = json.loads(open(path + 'k_enable.json').read(),
                                encoding='gbk')

        self.k_reply = k_Treturn.keys()
        self.k_reply.sort()

        for k_reply in self.k_reply:
            if k_Treturn[k_reply]:
                #print k_Treturn[k_reply]
                pagename = self.jsDir[k_reply][2]

                self.addpage = QtGui.QWidget()
                self.addpage.setObjectName(k_reply + "_replyPage")
                self.toolBox.insertItem(0, self.addpage, pagename)
                self.kvbreply = QtGui.QVBoxLayout(self.addpage)
                self.kvbreply.setObjectName(k_reply + "_replyPageLayout")
                self.kvbreply.setContentsMargins(0, 0, 0, 0)

                self.addListwidget = QtGui.QListWidget(self.addpage)
                self.addListwidget.setObjectName(k_reply +
                                                 "_replyPageListWidget")
                self.kvbreply.addWidget(self.addListwidget)

                for k_reply_node in k_Treturn[k_reply]:
                    self.klistItem = QtGui.QListWidgetItem(self.addListwidget)
                    self.klistItem.setText(k_reply_node)

        #self.toolBox.removeItem(0)

        Window2.setCentralWidget(self)
        Window2.show()
Esempio n. 44
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()
def _display_message(status, message):
    status_colors = {
        # status    gradientStart      gradientEnd          text
        'internal failure': ((255, 111, 105), (255, 111, 105), (0, 0, 0)),
        'fatal': ((255, 40, 20), (255, 40, 20), (0, 0, 0)),
        'warning': ((255, 177, 86), (255, 177, 86), (0, 0, 0)),
        'success': ((140, 230, 140), (140, 230, 140), (0, 0, 0)),
        'null': ((127, 127, 127), (127, 127, 127), (0, 0, 0))
    }

    # Recover the 'commandLine' QSplitter (its MayaUI name is always 'commandLine1')
    # noinspection PyCallByClass,PyTypeChecker
    command_line_ptr = maya.OpenMayaUI.MQtUtil.findControl('commandLine1')
    command_line = shiboken.wrapInstance(long(command_line_ptr),
                                         QtGui.QSplitter)

    # The 0th one is the messageLine (a <QLineEdit>)
    result_line = command_line.findChildren(QtGui.QLineEdit)[0]

    # Set the message
    # E.g. "[APOCALYPSE] Maya hates you (because probably you code sucks...)!")
    result_line.setText('[' + status.upper() + '] ' + message)

    # Customize colors (temporarily via a palette, not via a setStyleSheet which is permanent)
    """ I would like an HORIZONTAL_GRADIENT and RICH_TEXT"""
    palette = result_line.palette()
    palette.setColor(QtGui.QPalette.Text, QtGui.QColor(0, 0, 0))
    palette = result_line.palette()
    gradient = QtGui.QLinearGradient(
        QtCore.QRectF(result_line.rect()).topLeft(),
        QtCore.QRectF(result_line.rect()).topRight())
    gradient.setColorAt(0.0, QtGui.QColor(*status_colors[status][0]))
    gradient.setColorAt(1.0, QtGui.QColor(*status_colors[status][1]))
    palette.setBrush(QtGui.QPalette.Base, QtGui.QBrush(gradient))
    palette.setColor(QtGui.QPalette.Text,
                     QtGui.QColor(*status_colors[status][2]))
    result_line.setPalette(palette)
    pm.refresh()
Esempio n. 46
0
 def add_item(self,item_type,item_nm,lableTxt,con_func,menuLys):
     ptr = mui.MQtUtil.mainWindow()
     widget = wrapInstance(long(ptr), psqg.QWidget)
     maya_menu_bar = widget.findChild(psqg.QMenuBar)
     p_menu = maya_menu_bar
     for ea_arg in menuLys:
         tmp_menu = p_menu
         tmp_ch_menu = tmp_menu.findChild(psqg.QMenu, ea_arg)
         if tmp_ch_menu == None:
             p_menu = tmp_menu
             print("There is not a childe menu name:{}".format(ea_arg))
             break
         else: p_menu = tmp_ch_menu
     # p_menu.setStype
     if item_type in ['seperator', 'Seperator']:
         p_menu.addSeparator()
     elif item_type == 'menu':
         newMenu = p_menu.addMenu(item_nm)
     elif item_type == 'Action':
         new_item = p_menu.addAction(item_nm)
         new_item.setObjectName(item_nm)
         new_item.setText(lableTxt)
         new_item.triggered.connect(con_func)
Esempio n. 47
0
    def getBasePath(self):

        if int(cmds.about(v=1)) < 2017:
            import shiboken
            from PySide.QtGui import QFileDialog, QWidget, QDialog
        else:
            import shiboken2 as shiboken
            from PySide2.QtWidgets import QFileDialog, QWidget, QDialog

        winName = "dialog_getDirectory"
        mayaWin = shiboken.wrapInstance(
            long(maya.OpenMayaUI.MQtUtil.mainWindow()), QWidget)

        existing_widgets = mayaWin.findChildren(QDialog, winName)
        if existing_widgets: map(lambda x: x.deleteLater(), existing_widgets)

        dialog = QFileDialog(mayaWin)
        dialog.setObjectName(winName)
        dialog.setDirectory(os.path.splitext(cmds.file(q=1, sceneName=1))[0])
        choosedFolder = dialog.getExistingDirectory()
        if choosedFolder: self.lineEdit.setText(choosedFolder)

        self.cmd_loadList()
Esempio n. 48
0
 def setArea(self, area):
     '''Set the docking area
     '''
     # Skip setting the area if no area value passed in
     if area == Qt.NoDockWidgetArea:
         return
     # Mimic operations performed by Maya dockControl command
     mainWindowPtr = omui.MQtUtil.mainWindow()
     mainWindow = wrapInstance(long(mainWindowPtr), QMainWindow)
     childrenList = mainWindow.children()
     foundDockWidgetToTab = False
     for child in childrenList:
         # Create Tabbed dock if a QDockWidget already at that area
         if (child != self) and (isinstance(child, QDockWidget)):
             if not child.isHidden() and not child.isFloating():
                 if mainWindow.dockWidgetArea(child) == area:
                     mainWindow.tabifyDockWidget(child, self)
                     self.raise_()
                     foundDockWidgetToTab = True
                     break
     # If no other QDockWidget at that area, then just add it
     if not foundDockWidgetToTab:
         mainWindow.addDockWidget(area, self)
Esempio n. 49
0
def force_update(view):
    '''
    Selects the center of the viewport to force it to
    refresh properly in VP1. THIS IS AWFUL.

    :param view: View to convert point.
    :type view: OpenMaya.M3dView

    :raises: None

    :return: None
    :rtype: NoneType
    '''
    w = shiboken.wrapInstance(long(view.widget()), QtGui.QWidget)
    cur_pos = QtGui.QCursor.pos()
    p = w.mapToGlobal(w.rect().center())
    QtTest.QTest.mouseMove(w)
    QtTest.QTest.mousePress(
        w, QtCore.Qt.LeftButton, QtCore.Qt.AltModifier, p)
    QtTest.QTest.mouseRelease(
        w, QtCore.Qt.LeftButton, QtCore.Qt.AltModifier, p)
    QtGui.qApp.processEvents()
    QtGui.QCursor.setPos(cur_pos)
Esempio n. 50
0
def app_window():
    global APP_HANDLE

    if APP_HANDLE == None:
        if HOST == MAYA or HOST == MAYA2:
            mayaMainWindowPtr = omui.MQtUtil.mainWindow()
            mayaMainWindow = wrapInstance(long(mayaMainWindowPtr),
                                          Qt.QtWidgets.QWidget)
            APP_HANDLE = mayaMainWindow
        elif HOST == HOUDINI:
            #hou.ui.mainQtWindow()
            APP_HANDLE = hou.qt.mainWindow()
        elif HOST == NUKE:
            for obj in Qt.QtWidgets.QApplication.topLevelWidgets():
                if (obj.inherits('QMainWindow')
                        and obj.metaObject().className()
                        == 'Foundry::UI::DockMainWindow'):
                    APP_HANDLE = obj
        elif HOST == MAX:
            try:
                APP_HANDLE = MaxPlus.GetQMaxMainWindow(
                ) if QT5 else MaxPlus.GetQMaxWindow()
            except:
                # Max 2016
                pass
        elif HOST == C4D:
            # TODO: No Qt windows. Mb transform main window handle?
            pass
        elif HOST == BLENDER:
            # TODO: No Qt windows. Mb transform main window handle?
            pass
        elif HOST == KATANA:
            for obj in UI4.App.Application.QtGui.qApp.topLevelWidgets():
                if type(obj).__name__ == 'KatanaWindow':
                    APP_HANDLE = obj

    return APP_HANDLE
Esempio n. 51
0
    def dockArea(self):
        '''Return area if the widget is currently docked to the Maya MainWindow
        Will return None if not dockable
        
        :Return: str
        '''
        dockControlQt = self.parent()

        if not isinstance(dockControlQt, QDockWidget):
            return None
        else:
            mainWindowPtr = omui.MQtUtil.mainWindow()
            mainWindow = wrapInstance(long(mainWindowPtr), QMainWindow)
            dockAreaMap = {
                Qt.LeftDockWidgetArea: 'left',
                Qt.RightDockWidgetArea: 'right',
                Qt.TopDockWidgetArea: 'top',
                Qt.BottomDockWidgetArea: 'bottom',
                Qt.AllDockWidgetAreas: 'all',
                Qt.NoDockWidgetArea:
                'none',  # Note: 'none' not supported in maya dockControl command
            }
            dockWidgetAreaBitmap = mainWindow.dockWidgetArea(dockControlQt)
            return dockAreaMap[dockWidgetAreaBitmap]
Esempio n. 52
0
def shibokenGetMayaMainWindow():
    mayaMainWindowPtr = apiUI.MQtUtil.mainWindow()
    print(mayaMainWindowPtr)
    if mayaMainWindowPtr:
        mayaMainWindow = shiboken.wrapInstance(long(mayaMainWindowPtr),
                                               QtGui.QWidget)
        return mayaMainWindow
    else:
        return None


# def sipToQtObject(mayaName):
#    """
#    Convert a Maya ui path to a Qt object
#    @param mayaName: Maya UI Path to convert (Ex: "scriptEditorPanel1Window|TearOffPane|scriptEditorPanel1|testButton" )
#    @return: PyQt representation of that object
#    """
#    ptr = apiUI.MQtUtil.findControl(mayaName)
#    if ptr is None:
#        ptr = apiUI.MQtUtil.findLayout(mayaName)
#    if ptr is None:
#        ptr = apiUI.MQtUtil.findMenuItem(mayaName)
#    if ptr is not None:
#        return sip.wrapinstance(long(ptr), QtCore.QObject)
Esempio n. 53
0
def StartUI():
    if default == "pyqt4":
        MayaWindowPtr = sip.wrapinstance(long(mui.MQtUtil.mainWindow()),
                                         QtCore.QObject)
    else:
        MayaWindowPtr = shiboken.wrapInstance(long(mui.MQtUtil.mainWindow()),
                                              QtGui.QMainWindow)

    window_name = 'Control_Creator'
    dock_control = 'Control_Creator_Dock'

    if cmds.window(window_name, exists=True):
        cmds.deleteUI(window_name)
    Window = Hello(MayaWindowPtr)
    Window.setObjectName(window_name)
    if (cmds.dockControl(dock_control, q=True, ex=True)):
        cmds.deleteUI(dock_control)
    AllowedAreas = ['right', 'left']
    cmds.dockControl(dock_control,
                     aa=AllowedAreas,
                     a='left',
                     floating=False,
                     content=window_name,
                     label='Rig Creator')
Esempio n. 54
0
 def getMayaWindow():
     ptr = omui.MQtUtil.mainWindow()
     return wrapInstance(long(ptr), QtWidgets.QWidget)
Esempio n. 55
0
class Window_global:

    mayaWin = shiboken.wrapInstance(long(maya.OpenMayaUI.MQtUtil.mainWindow()),
                                    QWidget)
    title = "Put Object On Ground"
    width = 300
    height = 300

    infoPath = cmds.about(pd=True) + "/sg/putObjectOnGround/uiInfo.txt"
    makeFile(infoPath)

    mainGui = QMainWindow()
    listItems = []

    objectName = 'sgui_putObjectOnGround'
    listWidgetPutName = objectName + "_listPut"
    listWidgetGroundName = objectName + "_listGround"
    randomOptionRotName = objectName + "_randomRot"
    randomOptionScaleName = objectName + "_randomScale"
    randomOptionRotAName = objectName + "_randomRotAll"
    randomOptionScaleAName = objectName + "_randomScaleAll"
    offsetByObjectName = objectName + '_offsetObject'
    offsetByGroundName = objectName + '_offsetGround'
    checkNormalOrientName = objectName + '_checkNormalOrient'
    orientEditModeName = objectName + '_orientEditMode'
    duGroupListName = objectName + '_duGroupList'
    componentCheckName = objectName + '_componentCheck'

    @staticmethod
    def saveInfo2(filePath=None):

        if not filePath:
            filePath = Window_global.infoPath2

        rotateChecked = ''
        '''
        f = open( filePath, "w" )
        json.dump( , f, True, False, False )
        f.close()
        '''

    @staticmethod
    def loadInfo2(filePath=None):

        if not filePath:
            filePath = Window_global.infoPath2

        f = open(filePath, 'r')
        try:
            data = json.load(f)
        except:
            f.close()
            return None
        f.close()

    @staticmethod
    def saveInfo(filePath=None):

        if not filePath:
            filePath = Window_global.infoPath

        posX = Window_global.mainGui.pos().x()
        posY = Window_global.mainGui.pos().y()
        width = Window_global.mainGui.width()
        height = Window_global.mainGui.height()

        f = open(filePath, "w")
        json.dump([posX, posY, width, height], f, True, False, False)
        f.close()

    @staticmethod
    def loadInfo(filePath=None):

        if not filePath:
            filePath = Window_global.infoPath

        f = open(filePath, 'r')
        try:
            data = json.load(f)
        except:
            f.close()
            return None
        f.close()

        if not data: return None

        try:
            posX = data[0]
            posY = data[1]
            width = data[2]
            height = data[3]

            Window_global.mainGui.resize(width, height)

            desktop = QApplication.desktop()
            desktopWidth = desktop.width()
            desktopHeight = desktop.height()
            if posX + width > desktopWidth: posX = desktopWidth - width
            if posY + height > desktopWidth: posY = desktopHeight - height
            if posX < 0: posX = 0
            if posY < 0: posY = 0

            Window_global.mainGui.move(posX, posY)
        except:
            pass
Esempio n. 56
0
 def get_maya_window(self):
     """Grabs the Maya window."""
     pointer = mui.MQtUtil.mainWindow()
     return shiboken.wrapInstance(long(pointer), QtGui.QWidget)
Esempio n. 57
0
File: gui.py Progetto: xtoof/Tapp
def maya_main_window():
    main_window_ptr = omui.MQtUtil.mainWindow()
    return wrapInstance(long(main_window_ptr), QtGui.QWidget)
 def showWindows(self):
     image = os.environ['PIPELINE_PATH'] + "/Maya/Icon/Lib/"
     try:
         mayaWindowParent = shiboken.wrapInstance(long(omui.MQtUtil.mainWindow()), QtGui.QWidget)
         prt = mayaWindowParent
     except:
         prt = None
     palette = QtGui.QPalette()
     color = QtGui.QColor(0.4*255,0.5*255,0.5*255)
     palette.setColor(QtGui.QPalette.Background,color)
     palette.setColor(QtGui.QPalette.WindowText,QtGui.QColor(0,0,0))
     palette_white = QtGui.QPalette()
     palette_white.setColor(QtGui.QPalette.Background,QtGui.QColor(255,255,255))
     """set windows widget"""
     self.showGui = QtGui.QDialog(parent=prt)
     self.showGui.setModal(True)
     self.showGui.setWindowTitle('Mili')
     self.showGui.setAutoFillBackground(True)
     #self.showGui.setPalette(palette)
     self.imageformat = QtGui.QLabel('Image Format :')
     self.imageformat.setAlignment(QtCore.Qt.AlignVCenter|QtCore.Qt.AlignRight)
     self.imageformat.setMinimumHeight(20)
     self.imageformat.setAutoFillBackground(True)
     self.ImageFormatValue = QtGui.QLabel(self.renderInfo['ImageFormat'])
     self.ImageFormatValue.setAlignment(QtCore.Qt.AlignCenter)
     self.ImageFormatValue.setAutoFillBackground(True)
     self.Camera = QtGui.QLabel('Camera(AA) :')
     self.Camera.setAlignment(QtCore.Qt.AlignVCenter|QtCore.Qt.AlignRight)
     self.Camera.setAutoFillBackground(True)
     self.Camera.setMinimumHeight(20)
     self.CameraValue = QtGui.QLabel(str(self.renderInfo['CameraAA']))
     self.CameraValue.setAlignment(QtCore.Qt.AlignCenter)
     self.CameraValue.setAutoFillBackground(True)
     self.Diffuse = QtGui.QLabel('Diffuse :')
     self.Diffuse.setAlignment(QtCore.Qt.AlignVCenter|QtCore.Qt.AlignRight)
     self.Diffuse.setAutoFillBackground(True)
     self.Diffuse.setMinimumHeight(20)
     self.DiffuseValue = QtGui.QLabel(str(self.renderInfo['Diffuse']))
     self.DiffuseValue.setAlignment(QtCore.Qt.AlignCenter)
     self.DiffuseValue.setAutoFillBackground(True)
     self.Glossy = QtGui.QLabel('Glossy :')
     self.Glossy.setAlignment(QtCore.Qt.AlignVCenter|QtCore.Qt.AlignRight)
     self.Glossy.setAutoFillBackground(True)
     self.Glossy.setMinimumHeight(20)
     self.GlossyValue = QtGui.QLabel(str(self.renderInfo['Glossy']))
     self.GlossyValue.setAlignment(QtCore.Qt.AlignCenter)
     self.GlossyValue.setAutoFillBackground(True)
     self.Refraction = QtGui.QLabel('Refraction :')
     self.Refraction.setAlignment(QtCore.Qt.AlignVCenter|QtCore.Qt.AlignRight)
     self.Refraction.setAutoFillBackground(True)
     self.Refraction.setMinimumHeight(20)
     self.RefractionValue = QtGui.QLabel(str(self.renderInfo['Refraction']))
     self.RefractionValue.setAlignment(QtCore.Qt.AlignCenter)
     self.RefractionValue.setAutoFillBackground(True)
     self.sss = QtGui.QLabel('SSS :')
     self.sss.setAlignment(QtCore.Qt.AlignVCenter|QtCore.Qt.AlignRight)
     self.sss.setAutoFillBackground(True)
     self.sss.setMinimumHeight(20)
     self.sssValue = QtGui.QLabel(str(self.renderInfo['SSS']))
     self.sssValue.setAlignment(QtCore.Qt.AlignCenter)
     self.sssValue.setAutoFillBackground(True)
     self.VolumeIndirect = QtGui.QLabel('Volume Indirect :')
     self.VolumeIndirect.setAlignment(QtCore.Qt.AlignVCenter|QtCore.Qt.AlignRight)
     self.VolumeIndirect.setAutoFillBackground(True)
     self.VolumeIndirect.setMinimumHeight(20)
     self.VolumeIndirectValue = QtGui.QLabel(str(self.renderInfo['VolumeIndirect']))
     self.VolumeIndirectValue.setAlignment(QtCore.Qt.AlignCenter)
     self.VolumeIndirectValue.setAutoFillBackground(True)
     self.MotionBlurEnable = QtGui.QLabel('Motion Blur Enable :')
     self.MotionBlurEnable.setAlignment(QtCore.Qt.AlignVCenter|QtCore.Qt.AlignRight)
     self.MotionBlurEnable.setAutoFillBackground(True)
     self.MotionBlurEnable.setMinimumHeight(20)
     self.MotionBlurEnableValue = QtGui.QLabel(str(self.renderInfo['MotionBlurEnable']))
     self.MotionBlurEnableValue.setAlignment(QtCore.Qt.AlignCenter)
     self.MotionBlurEnableValue.setAutoFillBackground(True)
     self.MotionBlurEnableValue.setMinimumHeight(20)
     self.commontAOVs = QtGui.QLabel('Commont AOVs :')
     self.commontAOVs.setAlignment(QtCore.Qt.AlignVCenter|QtCore.Qt.AlignRight)
     self.commontAOVs.setAutoFillBackground(True)
     self.commontAOVs.setMinimumHeight(20)
     self.commontAOVsValue = QtGui.QLabel(self.renderInfo['CommontAOVs'])
     self.commontAOVsValue.setAlignment(QtCore.Qt.AlignCenter)
     self.commontAOVsValue.setAutoFillBackground(True)
     self.commontAOVsValue.setMinimumHeight(20)
     self.objectID = QtGui.QLabel('   Number of ObjectIDs :')
     self.objectID.setAlignment(QtCore.Qt.AlignVCenter|QtCore.Qt.AlignRight)
     self.objectID.setAutoFillBackground(True)
     self.objectID.setMinimumHeight(20)
     self.objectIDValue = QtGui.QLabel(str(self.renderInfo['ObjectID']))
     self.objectIDValue.setAlignment(QtCore.Qt.AlignCenter)
     self.objectIDValue.setAutoFillBackground(True)
     self.objectIDValue.setMinimumHeight(20)
     self.lightID = QtGui.QLabel('Number of LightIDs :')
     self.lightID.setAlignment(QtCore.Qt.AlignVCenter|QtCore.Qt.AlignRight)
     self.lightID.setAutoFillBackground(True)
     self.lightID.setMinimumHeight(20)
     self.lightIDValue = QtGui.QLabel(str(self.renderInfo['LightID']))
     self.lightIDValue.setAlignment(QtCore.Qt.AlignCenter)
     self.lightIDValue.setAutoFillBackground(True)
     self.lightIDValue.setMinimumHeight(20)
     gridLayout = QtGui.QGridLayout()
     gridLayout.setSpacing(1)
     gridLayout.addWidget(self.imageformat,1,0)
     gridLayout.addWidget(self.ImageFormatValue,1,1)
     gridLayout.addWidget(self.Camera,2,0)
     gridLayout.addWidget(self.CameraValue,2,1)
     gridLayout.addWidget(self.Diffuse,3,0)
     gridLayout.addWidget(self.DiffuseValue,3,1)
     gridLayout.addWidget(self.Glossy,4,0)
     gridLayout.addWidget(self.GlossyValue,4,1)
     gridLayout.addWidget(self.Refraction,5,0)
     gridLayout.addWidget(self.RefractionValue,5,1)
     gridLayout.addWidget(self.sss,6,0)
     gridLayout.addWidget(self.sssValue,6,1)
     gridLayout.addWidget(self.VolumeIndirect,7,0)
     gridLayout.addWidget(self.VolumeIndirectValue,7,1)
     gridLayout.addWidget(self.MotionBlurEnable,8,0)
     gridLayout.addWidget(self.MotionBlurEnableValue,8,1)
     gridLayout.addWidget(self.commontAOVs,9,0)
     gridLayout.addWidget(self.commontAOVsValue,9,1)
     gridLayout.addWidget(self.objectID,10,0)
     gridLayout.addWidget(self.objectIDValue,10,1)
     gridLayout.addWidget(self.lightID,11,0)
     gridLayout.addWidget(self.lightIDValue,11,1)
     groupBox = QtGui.QGroupBox('Informations')
     groupBox.setLayout(gridLayout)
     groupBox.setPalette(palette)
     self.showGui.setContentsMargins(0,0,0,0)#内容完全充满窗口
     title_layout = QtGui.QVBoxLayout()
     title = QtGui.QLabel('  Arnold Render Information  ')
     title.setMinimumHeight(30)
     title.setAlignment(QtCore.Qt.AlignCenter)
     title.setFont(QtGui.QFont("Rome times",10,QtGui.QFont.Bold))
     title.setAutoFillBackground(True)
     title.setPalette(palette)
     title_layout.addWidget(title)
     button = QtGui.QPushButton(u'确定')
     button.clicked.connect(self.makeSure)
     button.setMinimumHeight(30)
     button.setFont(QtGui.QFont("Rome times",10,QtGui.QFont.Bold))
     information_layout = QtGui.QVBoxLayout()
     information_layout.addWidget(groupBox)
     information_layout.setContentsMargins(10,10,10,0)
     edit_button = QtGui.QToolButton()
     edit_button.clicked.connect(self.showScriptEditGui)
     edit_button.setIcon(QtGui.QIcon(image+"gear.png"))
     edit_button.setIconSize(QtCore.QSize(21,21))
     button_layout = QtGui.QHBoxLayout()
     button_layout.addWidget(button)
     if self.isTD():
         button_layout.addWidget(edit_button)
     button_layout.setContentsMargins(10,0,10,10)
     button_layout.setSpacing(0)
     infoLayout = QtGui.QVBoxLayout()
     infoLayout.setSpacing(10)
     infoLayout.addLayout(title_layout)
     infoLayout.addLayout(information_layout)
     infoLayout.addStretch()
     infoLayout.addSpacing(30)
     infoLayout.addLayout(button_layout)
     infoLayout.addSpacing(10)
     self.mainLayout = QtGui.QHBoxLayout()
     self.mainLayout.setContentsMargins(0,0,0,0)
     self.mainLayout.setSpacing(10)
     self.mainLayout.addLayout(infoLayout)
     self.showGui.setLayout(self.mainLayout)
     flags = QtCore.Qt.WindowFlags()
     flags |= QtCore.Qt.Tool
     flags |= QtCore.Qt.WindowStaysOnTopHint
     try:
         self.setTestValue("Server")
         self.setColor()
     except:
         pass
     self.showGui.setWindowFlags(flags)
     self.showGui.show()
Esempio n. 59
0
 def maya_main_window(cls):
     main_window_ptr = omui.MQtUtil.mainWindow()
     return shiboken.wrapInstance(long(main_window_ptr), QtWidgets.QWidget)
Esempio n. 60
0
def getMayaWindow():
    ptr = OpenMayaUI.MQtUtil.mainWindow()
    return shiboken.wrapInstance(long(ptr), QtWidgets.QMainWindow)