Exemplo n.º 1
0
def wrapinstance(ptr, base=None):
    """
    Wraps given object in a Qt object
    :param ptr:
    :param base: QObject, base QWidget class we want to wrap given object
    :return:
    """

    if ptr is None:
        return None

    ptr = long(ptr)
    if 'shiboken' in globals():
        if base is None:
            qObj = shiboken.wrapInstance(long(ptr), QtCore.QObject)
            meta_obj = qObj.metaObject()
            cls = meta_obj.className()
            super_cls = meta_obj.superClass().className()
            if hasattr(QtGui, cls):
                base = getattr(QtGui, cls)
            elif hasattr(QtGui, super_cls):
                base = getattr(QtGui, super_cls)
            else:
                base = QtWidgets.QWidget
        try:
            return shiboken.wrapInstance(long(ptr), base)
        except Exception:
            from PySide.shiboken import wrapInstance
            return wrapInstance(long(ptr), base)
    elif 'sip' in globals():
        base = QtCore.QObject
        return shiboken.wrapinstance(long(ptr), base)
    else:
        logger.error('Failed to wrap object {} ...'.format(ptr))
        return None
Exemplo n.º 2
0
def wrapinstance(ptr, base=None):
    if ptr is None:
        return None

    ptr = long(ptr)
    if 'shiboken' in globals():
        if base is None:
            qObj = shiboken.wrapInstance(long(ptr), QObject)
            meta_obj = qObj.metaObject()
            cls = meta_obj.className()
            super_cls = meta_obj.superClass().className()
            if hasattr(QtGui, cls):
                base = getattr(QtGui, cls)
            elif hasattr(QtGui, super_cls):
                base = getattr(QtGui, super_cls)
            else:
                base = QWidget
        try:
            return shiboken.wrapInstance(long(ptr), base)
        except Exception:
            from PySide.shiboken import wrapInstance
            return wrapInstance(long(ptr), base)
    elif 'sip' in globals():
        base = QObject
        return shiboken.wrapinstance(long(ptr), base)
    else:
        print('Failed to wrap object ...')
        return None
Exemplo n.º 3
0
def ExampleDialog_Execute():
    """a simple example dialog showing basic functionality of the pyqt for softimage plugin"""
    from PySide import shiboken

    sianchor = Application.getQtSoftimageAnchor()
    sianchor = shiboken.wrapInstance( long(sianchor), QWidget )
    dialog = ExampleDialog( sianchor )
    dialog.show()
Exemplo n.º 4
0
def ExampleSignalSlot_Execute():
    """a simple example showing softimage events triggering pyqt signals"""
    from PySide import shiboken

    sianchor = Application.getQtSoftimageAnchor()
    sianchor = shiboken.wrapInstance( long(sianchor), QWidget )
    dialog = ExampleSignalSlot( sianchor )
    dialog.show()
Exemplo n.º 5
0
def ExampleMenu_Execute():
    """a simple example showing the use of a qmenu"""
    from PySide import shiboken
    
    sianchor = Application.getQtSoftimageAnchor()
    sianchor = shiboken.wrapInstance( long(sianchor), QWidget )
    menu = ExampleMenu( sianchor )
    
    # notice the use of QCursor and exec_ call
    menu.exec_(QCursor.pos())
Exemplo n.º 6
0
def getMayaWindow():
    
    try:
        ptr = mui.MQtUtil.mainWindow()
        
        if not ptr == None:
            return shiboken.wrapInstance(long(ptr), QtGui.QMainWindow)
        
    except AttributeError:
        
        return None
Exemplo n.º 7
0
def getMayaWindow():
    
    try:
        ptr = mui.MQtUtil.mainWindow()
        
        if not ptr == None:
            return shiboken.wrapInstance(long(ptr), QtGui.QMainWindow)
        
    except AttributeError:
        
        return None
Exemplo n.º 8
0
def _qtObject( address, type ) :

	global __qtModuleName
	if "PyQt" in __qtModuleName :
		import sip
		return sip.wrapinstance( address, type )
	else :
		try :
			import PySide.shiboken as shiboken
		except ImportError :
			import shiboken

		return shiboken.wrapInstance( address, type )
Exemplo n.º 9
0
def _qtObject(address, type):

    global __qtModuleName
    if "PyQt" in __qtModuleName:
        import sip
        return sip.wrapinstance(address, type)
    else:
        try:
            import PySide.shiboken as shiboken
        except ImportError:
            import shiboken

        return shiboken.wrapInstance(address, type)
Exemplo n.º 10
0
def wrapinstance(ptr, base=None):
    """convert a pointer to a Qt class instance (PySide/PyQt compatible)"""
    if ptr is None:
        return None
    ptr = long(ptr) #Ensure type
    if isPySide():
        from PySide import shiboken
        if base is None:
            qObj = shiboken.wrapInstance(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(ptr, base)
    elif isPyQt4():
        import sip
        return sip.wrapinstance(ptr, base)
    else:
        return None
Exemplo n.º 11
0
def wrapinstance(ptr, base=None):
    """convert a pointer to a Qt class instance (PySide/PyQt compatible)"""
    if ptr is None:
        return None
    ptr = long(ptr)  #Ensure type
    if isPySide():
        from PySide import shiboken
        if base is None:
            qObj = shiboken.wrapInstance(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(ptr, base)
    elif isPyQt4():
        import sip
        return sip.wrapinstance(ptr, base)
    else:
        return None
Exemplo n.º 12
0
 def WidgetCreate(self, pWidgetParent):
            
     #
     # IN parameter pWidgetparent is the memory address of the parent Qt widget. 
     #   here we should PySide.shiboken.wrapInstance() function to convert it to PySide.QtWidget object.
     #   and use it the as the parent for native Qt widgets created via Python. 
     #   Similiar approach is available in the sip python module for PyQt 
     #
     # Only a single widget is allowed to be the *direct* child of the IN parent widget. 
     #
     self.mNativeQtWidget = ReferencingSample.MainForm(shiboken.wrapInstance(pWidgetParent, QtGui.QWidget))
    
     #
     # return the memory address of the *single direct* child QWidget. 
     #
     return shiboken.getCppPointer(self.mNativeQtWidget)[0]
Exemplo n.º 13
0
    def WidgetCreate(self, pWidgetParent):

        #
        # IN parameter pWidgetparent is the memory address of the parent Qt widget.
        #   here we should PySide.shiboken.wrapInstance() function to convert it to PySide.QtWidget object.
        #   and use it the as the parent for native Qt widgets created via Python.
        #   Similiar approach is available in the sip python module for PyQt
        #
        # Only a single widget is allowed to be the *direct* child of the IN parent widget.
        #
        self.mNativeQtWidget = ReferencingSample.MainForm(
            shiboken.wrapInstance(pWidgetParent, QtGui.QWidget))

        #
        # return the memory address of the *single direct* child QWidget.
        #
        return shiboken.getCppPointer(self.mNativeQtWidget)[0]
Exemplo n.º 14
0
def getMayaWindow():
    ptr = OpenMayaUI.MQtUtil.mainWindow()
    return shiboken.wrapInstance(long(ptr), QtGui.QWidget)
Exemplo n.º 15
0
 def WidgetCreate(self, widgetParent):
     global the_window
     self.widget = VRayWindow(shiboken.wrapInstance(widgetParent, QtGui.QWidget))
     the_window = self.widget
     return shiboken.getCppPointer(self.widget)[0]
     
Exemplo n.º 16
0
	def WidgetCreate(self, pWidgetParent):
		self.mNativeQtWidget = Ui_TabWidget(shiboken.wrapInstance(pWidgetParent, QtGui.QWidget))
		return shiboken.getCppPointer(self.mNativeQtWidget)[0]
Exemplo n.º 17
0
def getMayaWindow():
    ptr = OpenMayaUI.MQtUtil.mainWindow()
    return shiboken.wrapInstance(long(ptr), QtGui.QWidget)
Exemplo n.º 18
0
def mainwindow():
    import pysidehooks_impl
    from PySide import QtGui, shiboken
    return shiboken.wrapInstance(pysidehooks_impl.mainwindow(), QtGui.QMainWindow)