Python sip.unwrapinstance() Examples
The following are 30
code examples of sip.unwrapinstance().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sip
, or try the search function
.
Example #1
Source File: outliner.py From tutorials with MIT License | 6 votes |
def showOutliner(cls): """ showOutliner() -> (str dockLayout, Outliner widget) Creates a Outliner widget inside of a Maya dockControl. Returns the dockControl path, and the Outliner widget. """ win = cls(parent=getMainWindow()) size = win.size() name = mui.MQtUtil.fullName(long(sip.unwrapinstance(win))) dock = cmds.dockControl( allowedArea='all', area='left', floating=False, content=name, width=size.width(), height=size.height(), label='Custom Outliner') return dock, win
Example #2
Source File: universal_tool_template_0904.py From universal_tool_template.py with MIT License | 6 votes |
def qt_to_mui(self, qt_obj): if hostMode != "maya": return ref = None if qtMode in (0,2): # ==== for pyside ==== ref = long(shiboken.getCppPointer(qt_obj)[0]) elif qtMode in (1,3): # ==== for PyQt==== ref = long(sip.unwrapinstance(qt_obj)) if ref is not None: return mui.MQtUtil.fullName(ref) ############################################# # User Class creation ############################################# # -------------------- # user module list # --------------------
Example #3
Source File: universal_tool_template_v8.1.py From universal_tool_template.py with MIT License | 6 votes |
def qt_to_mui(self, qt_obj): if hostMode != "maya": return ref = None if qtMode in (0,2): # ==== for pyside ==== ref = long(shiboken.getCppPointer(qt_obj)[0]) elif qtMode in (1,3): # ==== for PyQt==== ref = long(sip.unwrapinstance(qt_obj)) if ref is not None: return mui.MQtUtil.fullName(ref) ############################################# # window instance creation #############################################
Example #4
Source File: universal_tool_template_0903.py From universal_tool_template.py with MIT License | 6 votes |
def qt_to_mui(self, qt_obj): if hostMode != "maya": return ref = None if qtMode in (0,2): # ==== for pyside ==== ref = long(shiboken.getCppPointer(qt_obj)[0]) elif qtMode in (1,3): # ==== for PyQt==== ref = long(sip.unwrapinstance(qt_obj)) if ref is not None: return mui.MQtUtil.fullName(ref) ############################################# # User Class creation ############################################# # -------------------- # user module list # --------------------
Example #5
Source File: universal_tool_template_1110.py From universal_tool_template.py with MIT License | 6 votes |
def qt_to_mui(self, qt_obj): if hostMode != "maya": return ref = None if qtMode in (0,2): # ==== for pyside ==== ref = long(shiboken.getCppPointer(qt_obj)[0]) elif qtMode in (1,3): # ==== for PyQt==== ref = long(sip.unwrapinstance(qt_obj)) if ref is not None: return mui.MQtUtil.fullName(ref) #======================================= # widget specific functions #=======================================
Example #6
Source File: universal_tool_template_1100.py From universal_tool_template.py with MIT License | 6 votes |
def qt_to_mui(self, qt_obj): if hostMode != "maya": return ref = None if qtMode in (0,2): # ==== for pyside ==== ref = long(shiboken.getCppPointer(qt_obj)[0]) elif qtMode in (1,3): # ==== for PyQt==== ref = long(sip.unwrapinstance(qt_obj)) if ref is not None: return mui.MQtUtil.fullName(ref) #======================================= # widget specific functions #=======================================
Example #7
Source File: universal_tool_template_1115.py From universal_tool_template.py with MIT License | 6 votes |
def qt_to_mui(self, qt_obj): if hostMode != "maya": return ref = None if qtMode in (0,2): # ==== for pyside ==== ref = long(shiboken.getCppPointer(qt_obj)[0]) elif qtMode in (1,3): # ==== for PyQt==== ref = long(sip.unwrapinstance(qt_obj)) if ref is not None: return mui.MQtUtil.fullName(ref) #======================================= # widget specific functions #=======================================
Example #8
Source File: UITranslator.py From universal_tool_template.py with MIT License | 6 votes |
def qt_to_mui(self, qt_obj): if hostMode != "maya": return ref = None if qtMode in (0,2): # ==== for pyside ==== ref = long(shiboken.getCppPointer(qt_obj)[0]) elif qtMode in (1,3): # ==== for PyQt==== ref = long(sip.unwrapinstance(qt_obj)) if ref is not None: return mui.MQtUtil.fullName(ref) ############################################# # window instance creation #############################################
Example #9
Source File: GearBox_template_1010.py From universal_tool_template.py with MIT License | 6 votes |
def qt_to_mui(self, qt_obj): if hostMode != "maya": return ref = None if qtMode in (0,2): # ==== for pyside ==== ref = long(shiboken.getCppPointer(qt_obj)[0]) elif qtMode in (1,3): # ==== for PyQt==== ref = long(sip.unwrapinstance(qt_obj)) if ref is not None: return mui.MQtUtil.fullName(ref) #------------------------------ # TreeWidget Process Functions #------------------------------
Example #10
Source File: universal_tool_template_1020.py From universal_tool_template.py with MIT License | 6 votes |
def qt_to_mui(self, qt_obj): if hostMode != "maya": return ref = None if qtMode in (0,2): # ==== for pyside ==== ref = long(shiboken.getCppPointer(qt_obj)[0]) elif qtMode in (1,3): # ==== for PyQt==== ref = long(sip.unwrapinstance(qt_obj)) if ref is not None: return mui.MQtUtil.fullName(ref) #======================================= # widget specific functions #=======================================
Example #11
Source File: universal_tool_template_1116.py From universal_tool_template.py with MIT License | 6 votes |
def qt_to_mui(self, qt_obj): if hostMode != "maya": return ref = None if qtMode in (0,2): # ==== for pyside ==== ref = long(shiboken.getCppPointer(qt_obj)[0]) elif qtMode in (1,3): # ==== for PyQt==== ref = long(sip.unwrapinstance(qt_obj)) if ref is not None: return mui.MQtUtil.fullName(ref) #======================================= # widget specific functions #=======================================
Example #12
Source File: universal_tool_template_1010.py From universal_tool_template.py with MIT License | 6 votes |
def qt_to_mui(self, qt_obj): if hostMode != "maya": return ref = None if qtMode in (0,2): # ==== for pyside ==== ref = long(shiboken.getCppPointer(qt_obj)[0]) elif qtMode in (1,3): # ==== for PyQt==== ref = long(sip.unwrapinstance(qt_obj)) if ref is not None: return mui.MQtUtil.fullName(ref) #------------------------------ # TreeWidget Process Functions #------------------------------
Example #13
Source File: outliner2.py From tutorials with MIT License | 6 votes |
def showOutliner(cls): """ showOutliner() -> (str dockLayout, Outliner widget) Creates a Outliner widget inside of a Maya dockControl. Returns the dockControl path, and the Outliner widget. """ win = cls(parent=getMainWindow()) size = win.size() name = mui.MQtUtil.fullName(long(sip.unwrapinstance(win))) dock = cmds.dockControl( allowedArea='all', area='left', floating=False, content=name, width=size.width(), height=size.height(), label='Custom Outliner') return dock, win
Example #14
Source File: outliner3.py From tutorials with MIT License | 6 votes |
def showOutliner(cls): """ showOutliner() -> (str dockLayout, Outliner widget) Creates a Outliner widget inside of a Maya dockControl. Returns the dockControl path, and the Outliner widget. """ win = cls(parent=getMainWindow()) size = win.size() name = mui.MQtUtil.fullName(long(sip.unwrapinstance(win))) dock = cmds.dockControl( allowedArea='all', area='left', floating=True, content=name, width=size.width(), height=size.height(), label='Custom Outliner') return dock, win
Example #15
Source File: channelBox.py From tutorials with MIT License | 6 votes |
def showChannelBox(cls): """ showChannelBox() -> (str dockLayout, ChannelBox widget) Creates a ChannelBox widget inside of a Maya dockControl. Returns the dockControl path, and the ChannelBox widget. """ win = cls(parent=getMainWindow()) size = win.size() name = mui.MQtUtil.fullName(long(sip.unwrapinstance(win))) dock = cmds.dockControl( allowedArea='all', area='right', floating=True, content=name, width=size.width(), height=size.height(), label='Custom ChannelBox') return dock, win
Example #16
Source File: Qt.py From dm2skin with The Unlicense | 6 votes |
def _pyqt5(): """Initialise PyQt5""" import PyQt5 as module _setup(module, ["uic"]) try: import sip Qt.QtCompat.wrapInstance = ( lambda ptr, base=None: _wrapinstance( sip.wrapinstance, ptr, base) ) Qt.QtCompat.getCppPointer = lambda object: \ sip.unwrapinstance(object) except ImportError: pass # Optional if hasattr(Qt, "_uic"): Qt.QtCompat.loadUi = _loadUi if hasattr(Qt, "_QtCore"): Qt.__binding_version__ = Qt._QtCore.PYQT_VERSION_STR Qt.__qt_version__ = Qt._QtCore.QT_VERSION_STR Qt.QtCompat.translate = Qt._QtCore.QCoreApplication.translate if hasattr(Qt, "_QtWidgets"): Qt.QtCompat.setSectionResizeMode = \ Qt._QtWidgets.QHeaderView.setSectionResizeMode _reassign_misplaced_members("pyqt5")
Example #17
Source File: Qt.py From NukeToolSet with MIT License | 6 votes |
def _pyqt5(): """Initialise PyQt5""" import PyQt5 as module _setup(module, ["uic"]) try: import sip Qt.QtCompat.wrapInstance = ( lambda ptr, base=None: _wrapinstance( sip.wrapinstance, ptr, base) ) Qt.QtCompat.getCppPointer = lambda object: \ sip.unwrapinstance(object) except ImportError: pass # Optional if hasattr(Qt, "_uic"): Qt.QtCompat.loadUi = _loadUi if hasattr(Qt, "_QtCore"): Qt.__binding_version__ = Qt._QtCore.PYQT_VERSION_STR Qt.__qt_version__ = Qt._QtCore.QT_VERSION_STR Qt.QtCompat.translate = Qt._QtCore.QCoreApplication.translate if hasattr(Qt, "_QtWidgets"): Qt.QtCompat.setSectionResizeMode = \ Qt._QtWidgets.QHeaderView.setSectionResizeMode _reassign_misplaced_members("pyqt5")
Example #18
Source File: GraphicsScene.py From soapy with GNU General Public License v3.0 | 6 votes |
def getViewWidget(self): return self.views()[0] #def getViewWidget(self, widget): ### same pyqt bug -- mouseEvent.widget() doesn't give us the original python object. ### [[doesn't seem to work correctly]] #if HAVE_SIP and isinstance(self, sip.wrapper): #addr = sip.unwrapinstance(sip.cast(widget, QtGui.QWidget)) ##print "convert", widget, addr #for v in self.views(): #addr2 = sip.unwrapinstance(sip.cast(v, QtGui.QWidget)) ##print " check:", v, addr2 #if addr2 == addr: #return v #else: #return widget
Example #19
Source File: GraphicsScene.py From tf-pose with Apache License 2.0 | 6 votes |
def getViewWidget(self): return self.views()[0] #def getViewWidget(self, widget): ### same pyqt bug -- mouseEvent.widget() doesn't give us the original python object. ### [[doesn't seem to work correctly]] #if HAVE_SIP and isinstance(self, sip.wrapper): #addr = sip.unwrapinstance(sip.cast(widget, QtGui.QWidget)) ##print "convert", widget, addr #for v in self.views(): #addr2 = sip.unwrapinstance(sip.cast(v, QtGui.QWidget)) ##print " check:", v, addr2 #if addr2 == addr: #return v #else: #return widget
Example #20
Source File: GraphicsScene.py From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 | 6 votes |
def getViewWidget(self): return self.views()[0] #def getViewWidget(self, widget): ### same pyqt bug -- mouseEvent.widget() doesn't give us the original python object. ### [[doesn't seem to work correctly]] #if HAVE_SIP and isinstance(self, sip.wrapper): #addr = sip.unwrapinstance(sip.cast(widget, QtGui.QWidget)) ##print "convert", widget, addr #for v in self.views(): #addr2 = sip.unwrapinstance(sip.cast(v, QtGui.QWidget)) ##print " check:", v, addr2 #if addr2 == addr: #return v #else: #return widget
Example #21
Source File: GraphicsScene.py From soapy with GNU General Public License v3.0 | 5 votes |
def selectedItems(self, *args): items = QtGui.QGraphicsScene.selectedItems(self, *args) ## PyQt bug: items() returns a list of QGraphicsItem instances. If the item is subclassed from QGraphicsObject, ## then the object returned will be different than the actual item that was originally added to the scene #if HAVE_SIP and isinstance(self, sip.wrapper): #items2 = [] #for i in items: #addr = sip.unwrapinstance(sip.cast(i, QtGui.QGraphicsItem)) #i2 = GraphicsScene._addressCache.get(addr, i) ##print i, "==>", i2 #items2.append(i2) items2 = list(map(self.translateGraphicsItem, items)) #print 'items:', items return items2
Example #22
Source File: GraphicsScene.py From soapy with GNU General Public License v3.0 | 5 votes |
def itemAt(self, *args): item = QtGui.QGraphicsScene.itemAt(self, *args) ## PyQt bug: items() returns a list of QGraphicsItem instances. If the item is subclassed from QGraphicsObject, ## then the object returned will be different than the actual item that was originally added to the scene #if HAVE_SIP and isinstance(self, sip.wrapper): #addr = sip.unwrapinstance(sip.cast(item, QtGui.QGraphicsItem)) #item = GraphicsScene._addressCache.get(addr, item) #return item return self.translateGraphicsItem(item)
Example #23
Source File: debug.py From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 | 5 votes |
def listQThreads(): """Prints Thread IDs (Qt's, not OS's) for all QThreads.""" thr = findObj('[Tt]hread') thr = [t for t in thr if isinstance(t, QtCore.QThread)] import sip for t in thr: print("--> ", t) print(" Qt ID: 0x%x" % sip.unwrapinstance(t))
Example #24
Source File: debug.py From soapy with GNU General Public License v3.0 | 5 votes |
def listQThreads(): """Prints Thread IDs (Qt's, not OS's) for all QThreads.""" thr = findObj('[Tt]hread') thr = [t for t in thr if isinstance(t, QtCore.QThread)] import sip for t in thr: print("--> ", t) print(" Qt ID: 0x%x" % sip.unwrapinstance(t))
Example #25
Source File: GraphicsScene.py From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 | 5 votes |
def registerObject(cls, obj): """ Workaround for PyQt bug in qgraphicsscene.items() All subclasses of QGraphicsObject must register themselves with this function. (otherwise, mouse interaction with those objects will likely fail) """ if HAVE_SIP and isinstance(obj, sip.wrapper): cls._addressCache[sip.unwrapinstance(sip.cast(obj, QtGui.QGraphicsItem))] = obj
Example #26
Source File: GraphicsScene.py From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 | 5 votes |
def items(self, *args): #print 'args:', args items = QtGui.QGraphicsScene.items(self, *args) ## PyQt bug: items() returns a list of QGraphicsItem instances. If the item is subclassed from QGraphicsObject, ## then the object returned will be different than the actual item that was originally added to the scene items2 = list(map(self.translateGraphicsItem, items)) #if HAVE_SIP and isinstance(self, sip.wrapper): #items2 = [] #for i in items: #addr = sip.unwrapinstance(sip.cast(i, QtGui.QGraphicsItem)) #i2 = GraphicsScene._addressCache.get(addr, i) ##print i, "==>", i2 #items2.append(i2) #print 'items:', items return items2
Example #27
Source File: GraphicsScene.py From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 | 5 votes |
def selectedItems(self, *args): items = QtGui.QGraphicsScene.selectedItems(self, *args) ## PyQt bug: items() returns a list of QGraphicsItem instances. If the item is subclassed from QGraphicsObject, ## then the object returned will be different than the actual item that was originally added to the scene #if HAVE_SIP and isinstance(self, sip.wrapper): #items2 = [] #for i in items: #addr = sip.unwrapinstance(sip.cast(i, QtGui.QGraphicsItem)) #i2 = GraphicsScene._addressCache.get(addr, i) ##print i, "==>", i2 #items2.append(i2) items2 = list(map(self.translateGraphicsItem, items)) #print 'items:', items return items2
Example #28
Source File: GraphicsScene.py From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 | 5 votes |
def itemAt(self, *args): item = QtGui.QGraphicsScene.itemAt(self, *args) ## PyQt bug: items() returns a list of QGraphicsItem instances. If the item is subclassed from QGraphicsObject, ## then the object returned will be different than the actual item that was originally added to the scene #if HAVE_SIP and isinstance(self, sip.wrapper): #addr = sip.unwrapinstance(sip.cast(item, QtGui.QGraphicsItem)) #item = GraphicsScene._addressCache.get(addr, item) #return item return self.translateGraphicsItem(item)
Example #29
Source File: GraphicsScene.py From tf-pose with Apache License 2.0 | 5 votes |
def registerObject(cls, obj): """ Workaround for PyQt bug in qgraphicsscene.items() All subclasses of QGraphicsObject must register themselves with this function. (otherwise, mouse interaction with those objects will likely fail) """ if HAVE_SIP and isinstance(obj, sip.wrapper): cls._addressCache[sip.unwrapinstance(sip.cast(obj, QtGui.QGraphicsItem))] = obj
Example #30
Source File: GraphicsScene.py From soapy with GNU General Public License v3.0 | 5 votes |
def items(self, *args): #print 'args:', args items = QtGui.QGraphicsScene.items(self, *args) ## PyQt bug: items() returns a list of QGraphicsItem instances. If the item is subclassed from QGraphicsObject, ## then the object returned will be different than the actual item that was originally added to the scene items2 = list(map(self.translateGraphicsItem, items)) #if HAVE_SIP and isinstance(self, sip.wrapper): #items2 = [] #for i in items: #addr = sip.unwrapinstance(sip.cast(i, QtGui.QGraphicsItem)) #i2 = GraphicsScene._addressCache.get(addr, i) ##print i, "==>", i2 #items2.append(i2) #print 'items:', items return items2