Python PySide2.QtCore.QObject() Examples

The following are 29 code examples of PySide2.QtCore.QObject(). 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 PySide2.QtCore , or try the search function .
Example #1
Source File: pyside_test.py    From pivy with ISC License 7 votes vote down vote up
def testAdresses(self):
        q = QtCore.QObject()
        ptr = wrapper.getCppPointer(q)
        print("CppPointer to an instance of PySide.QtCore.QObject = 0x%016X" % ptr[0])

        # None of the following is expected to raise an
        # OverflowError on 64-bit systems

        # largest 32-bit address
        wrapper.wrapInstance(0xFFFFFFFF, QtCore.QObject)

        # a regular, slightly smaller 32-bit address
        wrapper.wrapInstance(0xFFFFFFF, QtCore.QObject)

        # an actual 64-bit address (> 4 GB, the first non 32-bit address)
        wrapper.wrapInstance(0x100000000, QtCore.QObject)

        # largest 64-bit address
        wrapper.wrapInstance(0xFFFFFFFFFFFFFFFF, QtCore.QObject) 
Example #2
Source File: loaders.py    From pylash_engine with MIT License 6 votes vote down vote up
def _onMediaStatusChanged(self, status):
		if status == QtMultimedia.QMediaPlayer.MediaStatus.LoadedMedia:
			QtCore.QObject.disconnect(
				self.content,
				QtCore.SIGNAL("mediaStatusChanged()"),
				self.content._mediaStatusChangedSlot
			)
			QtCore.QObject.disconnect(
				self.content,
				QtCore.SIGNAL("error()"),
				self.content._errorSlot
			)
			
			e = Event(LoaderEvent.COMPLETE)
			e.target = self.content
			self.dispatchEvent(e) 
Example #3
Source File: window_utils.py    From spore with MIT License 6 votes vote down vote up
def get_layout(layout):
    """ return a layout wraped as QObject """
    ptr = omui.MQtUtil.findLayout(layout)
    return shiboken2.wrapInstance(long(ptr), QWidget) #.layout() 
Example #4
Source File: blender_application.py    From bqt with Mozilla Public License 2.0 6 votes vote down vote up
def notify(self, receiver: QObject, event: QEvent) -> bool:
        """
        Args:
            receiver: Object to recieve event
            event: Event

        Returns: bool
        """

        if isinstance(event, QCloseEvent) and receiver in (self.blender_widget, self._blender_window):
            event.ignore()
            self.store_window_geometry()
            self.should_close = True
            return False

        return super().notify(receiver, event) 
Example #5
Source File: FileSystemItem.py    From pyrdp with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, name: str, itemType: FileSystemItemType, parent: QObject = None):
        if itemType == FileSystemItemType.Drive:
            iconType = QFileIconProvider.IconType.Drive
        elif itemType == FileSystemItemType.Directory:
            iconType = QFileIconProvider.IconType.Folder
        else:
            iconType = QFileIconProvider.IconType.File

        icon = FileSystemItem._iconCache.get(iconType, None)

        if icon is None:
            icon = QFileIconProvider().icon(iconType)
            FileSystemItem._iconCache[iconType] = icon

        super().__init__(icon, name, parent)
        self.itemType = itemType 
Example #6
Source File: _compat.py    From mGui with MIT License 6 votes vote down vote up
def _pyside2_as_qt_object(widget):
    from PySide2.QtCore import QObject
    from PySide2.QtWidgets import QWidget
    from PySide2 import QtWidgets
    from shiboken2 import wrapInstance
    if hasattr(widget, '__qt_object__'):
        return widget.__qt_object__
    ptr = _find_widget_ptr(widget)
    qobject = wrapInstance(long(ptr), QObject)
    meta = qobject.metaObject()
    _class = meta.className()
    _super = meta.superClass().className()
    qclass = getattr(QtWidgets, _class, getattr(QtWidgets, _super, QWidget))
    return wrapInstance(long(ptr), qclass) 
Example #7
Source File: _compat.py    From mGui with MIT License 6 votes vote down vote up
def _pyside_as_qt_object(widget):
    from PySide.QtCore import QObject
    from PySide.QtGui import QWidget
    from PySide import QtGui
    from shiboken import wrapInstance
    if hasattr(widget, '__qt_object__'):
        return widget.__qt_object__
    ptr = _find_widget_ptr(widget)
    qobject = wrapInstance(long(ptr), QObject)
    meta = qobject.metaObject()
    _class = meta.className()
    _super = meta.superClass().className()
    qclass = getattr(QtGui, _class, getattr(QtGui, _super, QWidget))
    return wrapInstance(long(ptr), qclass) 
Example #8
Source File: FileSystemWidget.py    From pyrdp with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, root: Directory, parent: QObject = None):
        """
        :param root: root of all directories. Directories in root will be displayed with drive icons.
        :param parent: parent object.
        """

        super().__init__(parent)
        self.root = root
        self.breadcrumbLabel = QLabel()

        self.titleLabel = QLabel()
        self.titleLabel.setStyleSheet("font-weight: bold")

        self.titleSeparator: QFrame = QFrame()
        self.titleSeparator.setFrameShape(QFrame.HLine)

        self.listWidget = QListWidget()
        self.listWidget.setSortingEnabled(True)
        self.listWidget.setContextMenuPolicy(Qt.CustomContextMenu)
        self.listWidget.customContextMenuRequested.connect(self.onCustomContextMenu)

        self.verticalLayout = QVBoxLayout()
        self.verticalLayout.addWidget(self.breadcrumbLabel)
        self.verticalLayout.addWidget(self.listWidget)

        self.setLayout(self.verticalLayout)
        self.listWidget.itemDoubleClicked.connect(self.onItemDoubleClicked)

        self.currentPath: Path = Path("/")
        self.currentDirectory: Directory = root
        self.listCurrentDirectory()

        self.currentDirectory.addObserver(self) 
Example #9
Source File: tests.py    From Qt.py with MIT License 5 votes vote down vote up
def test_isValid():
        """.isValid and .delete work in all bindings"""
        from Qt import QtCompat, QtCore
        obj = QtCore.QObject()
        assert QtCompat.isValid(obj)
        QtCompat.delete(obj)
        assert not QtCompat.isValid(obj) 
Example #10
Source File: tests.py    From Qt.py with MIT License 5 votes vote down vote up
def test_load_ui_returntype():
    """load_ui returns an instance of QObject"""

    import sys
    from Qt import QtWidgets, QtCore, QtCompat
    app = QtWidgets.QApplication(sys.argv)
    obj = QtCompat.loadUi(self.ui_qwidget)
    assert isinstance(obj, QtCore.QObject)
    app.exit() 
Example #11
Source File: darwin_blender_application.py    From bqt with Mozilla Public License 2.0 5 votes vote down vote up
def _on_focus_object_changed(self, focus_object: QObject):
        """
        Args:
            focus_object: Object to track focus event
        """

        if focus_object is self.blender_widget:
            self._ns_window.makeKey() 
Example #12
Source File: win32_blender_application.py    From bqt with Mozilla Public License 2.0 5 votes vote down vote up
def _on_focus_object_changed(self, focus_object: QObject):
        """
        Args:
            QObject focus_object: Object to track focus change
        """

        if focus_object is self.blender_widget:
            win32gui.SetFocus(self._hwnd) 
Example #13
Source File: blender_application.py    From bqt with Mozilla Public License 2.0 5 votes vote down vote up
def _on_focus_object_changed(self, focus_object: QObject):
        """
        Args:
            focus_object: Object to track focus event
        """

        pass 
Example #14
Source File: universal_tool_template_v8.1.py    From universal_tool_template.py with MIT License 5 votes vote down vote up
def mui_to_qt(self, mui_name):
        if hostMode != "maya":
            return
        ptr = mui.MQtUtil.findControl(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findLayout(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findMenuItem(mui_name)
        if ptr is not None:
            if qtMode in (0,2):
                # ==== for pyside ====
                return shiboken.wrapInstance(long(ptr), QtWidgets.QWidget)
            elif qtMode in (1,3):
                # ==== for PyQt====
                return sip.wrapinstance(long(ptr), QtCore.QObject) 
Example #15
Source File: universal_tool_template_1000.py    From universal_tool_template.py with MIT License 5 votes vote down vote up
def mui_to_qt(self, mui_name):
        if hostMode != "maya":
            return
        ptr = mui.MQtUtil.findControl(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findLayout(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findMenuItem(mui_name)
        if ptr is not None:
            if qtMode in (0,2):
                # ==== for pyside ====
                return shiboken.wrapInstance(long(ptr), QtWidgets.QWidget)
            elif qtMode in (1,3):
                # ==== for PyQt====
                return sip.wrapinstance(long(ptr), QtCore.QObject) 
Example #16
Source File: universal_tool_template_0904.py    From universal_tool_template.py with MIT License 5 votes vote down vote up
def mui_to_qt(self, mui_name):
        if hostMode != "maya":
            return
        ptr = mui.MQtUtil.findControl(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findLayout(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findMenuItem(mui_name)
        if ptr is not None:
            if qtMode in (0,2):
                # ==== for pyside ====
                return shiboken.wrapInstance(long(ptr), QtWidgets.QWidget)
            elif qtMode in (1,3):
                # ==== for PyQt====
                return sip.wrapinstance(long(ptr), QtCore.QObject) 
Example #17
Source File: universal_tool_template_0903.py    From universal_tool_template.py with MIT License 5 votes vote down vote up
def mui_to_qt(self, mui_name):
        if hostMode != "maya":
            return
        ptr = mui.MQtUtil.findControl(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findLayout(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findMenuItem(mui_name)
        if ptr is not None:
            if qtMode in (0,2):
                # ==== for pyside ====
                return shiboken.wrapInstance(long(ptr), QtWidgets.QWidget)
            elif qtMode in (1,3):
                # ==== for PyQt====
                return sip.wrapinstance(long(ptr), QtCore.QObject) 
Example #18
Source File: universal_tool_template_1110.py    From universal_tool_template.py with MIT License 5 votes vote down vote up
def mui_to_qt(self, mui_name):
        if hostMode != "maya":
            return
        ptr = mui.MQtUtil.findControl(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findLayout(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findMenuItem(mui_name)
        if ptr is not None:
            if qtMode in (0,2):
                # ==== for pyside ====
                return shiboken.wrapInstance(long(ptr), QtWidgets.QWidget)
            elif qtMode in (1,3):
                # ==== for PyQt====
                return sip.wrapinstance(long(ptr), QtCore.QObject) 
Example #19
Source File: universal_tool_template_1100.py    From universal_tool_template.py with MIT License 5 votes vote down vote up
def mui_to_qt(self, mui_name):
        if hostMode != "maya":
            return
        ptr = mui.MQtUtil.findControl(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findLayout(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findMenuItem(mui_name)
        if ptr is not None:
            if qtMode in (0,2):
                # ==== for pyside ====
                return shiboken.wrapInstance(long(ptr), QtWidgets.QWidget)
            elif qtMode in (1,3):
                # ==== for PyQt====
                return sip.wrapinstance(long(ptr), QtCore.QObject) 
Example #20
Source File: universal_tool_template_1112.py    From universal_tool_template.py with MIT License 5 votes vote down vote up
def mui_to_qt(self, mui_name):
        if hostMode != "maya":
            return
        ptr = mui.MQtUtil.findControl(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findLayout(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findMenuItem(mui_name)
        if ptr is not None:
            if qtMode in (0,2):
                # ==== for pyside ====
                return shiboken.wrapInstance(long(ptr), QtWidgets.QWidget)
            elif qtMode in (1,3):
                # ==== for PyQt====
                return sip.wrapinstance(long(ptr), QtCore.QObject) 
Example #21
Source File: UITranslator.py    From universal_tool_template.py with MIT License 5 votes vote down vote up
def mui_to_qt(self, mui_name):
        if hostMode != "maya":
            return
        ptr = mui.MQtUtil.findControl(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findLayout(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findMenuItem(mui_name)
        if ptr is not None:
            if qtMode in (0,2):
                # ==== for pyside ====
                return shiboken.wrapInstance(long(ptr), QtWidgets.QWidget)
            elif qtMode in (1,3):
                # ==== for PyQt====
                return sip.wrapinstance(long(ptr), QtCore.QObject) 
Example #22
Source File: GearBox_template_1010.py    From universal_tool_template.py with MIT License 5 votes vote down vote up
def mui_to_qt(self, mui_name):
        if hostMode != "maya":
            return
        ptr = mui.MQtUtil.findControl(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findLayout(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findMenuItem(mui_name)
        if ptr is not None:
            if qtMode in (0,2):
                # ==== for pyside ====
                return shiboken.wrapInstance(long(ptr), QtWidgets.QWidget)
            elif qtMode in (1,3):
                # ==== for PyQt====
                return sip.wrapinstance(long(ptr), QtCore.QObject) 
Example #23
Source File: universal_tool_template_1020.py    From universal_tool_template.py with MIT License 5 votes vote down vote up
def mui_to_qt(self, mui_name):
        if hostMode != "maya":
            return
        ptr = mui.MQtUtil.findControl(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findLayout(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findMenuItem(mui_name)
        if ptr is not None:
            if qtMode in (0,2):
                # ==== for pyside ====
                return shiboken.wrapInstance(long(ptr), QtWidgets.QWidget)
            elif qtMode in (1,3):
                # ==== for PyQt====
                return sip.wrapinstance(long(ptr), QtCore.QObject) 
Example #24
Source File: universal_tool_template_1116.py    From universal_tool_template.py with MIT License 5 votes vote down vote up
def mui_to_qt(self, mui_name):
        if hostMode != "maya":
            return
        ptr = mui.MQtUtil.findControl(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findLayout(mui_name)
        if ptr is None:
            ptr = mui.MQtUtil.findMenuItem(mui_name)
        if ptr is not None:
            if qtMode in (0,2):
                # ==== for pyside ====
                return shiboken.wrapInstance(long(ptr), QtWidgets.QWidget)
            elif qtMode in (1,3):
                # ==== for PyQt====
                return sip.wrapinstance(long(ptr), QtCore.QObject) 
Example #25
Source File: FileDownloadDialog.py    From pyrdp with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, remotePath: str, targetPath: str, isMultipleDownload: bool, parent: QObject):
        super().__init__(parent, Qt.CustomizeWindowHint | Qt.WindowTitleHint)
        self.titleLabel = QLabel(f"Downloading {remotePath} to {targetPath}")

        self.progressBar = QProgressBar()
        self.progressBar.setMinimum(0)
        self.progressBar.setMaximum(0)


        self.actualProgress = 0
        self.actualMaximum = 0
        self.isComplete = False

        self.isMultipleDownload = isMultipleDownload
        self.downloadCount = 0
        self.downloadTotal = 0

        self.progressLabel = QLabel(f"{self.downloadCount} / {self.downloadTotal} files downloaded")
        self.progressSizeLabel = QLabel("0 bytes")

        self.widgetLayout = QVBoxLayout()
        self.widgetLayout.addWidget(self.titleLabel)
        self.widgetLayout.addWidget(self.progressLabel)
        self.widgetLayout.addWidget(self.progressBar)
        self.widgetLayout.addWidget(self.progressSizeLabel)

        self.closeButton = QPushButton("Continue download in background")
        self.closeButton.clicked.connect(self.hide)
        self.widgetLayout.addWidget(self.closeButton)

        self.setLayout(self.widgetLayout) 
Example #26
Source File: universal_tool_template_0903.py    From universal_tool_template.py with MIT License 4 votes vote down vote up
def main(mode=0):
    # get parent window in Maya
    parentWin = None
    if hostMode == "maya":
        if qtMode in (0,2): # pyside
            parentWin = shiboken.wrapInstance(long(mui.MQtUtil.mainWindow()), QtWidgets.QWidget)
        elif qtMode in (1,3): # PyQt
            parentWin = sip.wrapinstance(long(mui.MQtUtil.mainWindow()), QtCore.QObject)
    # create app object for certain host
    app = None
    if hostMode in ("desktop", "blender"):
        app = QtWidgets.QApplication(sys.argv)
    
    #--------------------------
    # ui instance
    #--------------------------
    # template 1 - Keep only one copy of windows ui in Maya
    global single_UserClassUI
    if single_UserClassUI is None:
        if hostMode == "maya":
            single_UserClassUI = UserClassUI(parentWin, mode)
        else:
            single_UserClassUI = UserClassUI()
        # extra note: in Maya () for no parent; (parentWin,0) for extra mode input
    single_UserClassUI.show()
    ui = single_UserClassUI
    
    # template 2 - allow loading multiple windows of same UI in Maya
    '''
    if hostMode == "maya":
        ui = UserClassUI(parentWin)
        ui.show()
    else:
        
    # extra note: in Maya () for no parent; (parentWin,0) for extra mode input
    
    '''
    
    # loop app object for certain host
    if hostMode in ("desktop"):
        sys.exit(app.exec_())
    
    return ui 
Example #27
Source File: universal_tool_template_0803.py    From universal_tool_template.py with MIT License 4 votes vote down vote up
def main(mode=0):
    # get parent window in Maya
    parentWin = None
    if hostMode == "maya":
        if qtMode in (0,2): # pyside
            parentWin = shiboken.wrapInstance(long(mui.MQtUtil.mainWindow()), QtWidgets.QWidget)
        elif qtMode in (1,3): # PyQt
            parentWin = sip.wrapinstance(long(mui.MQtUtil.mainWindow()), QtCore.QObject)
    # create app object for certain host
    app = None
    if hostMode in ("desktop", "blender"):
        app = QtWidgets.QApplication(sys.argv)
    
    #--------------------------
    # ui instance
    #--------------------------
    # template 1 - Keep only one copy of windows ui in Maya
    global single_UniversalToolUI
    if single_UniversalToolUI is None:
        if hostMode == "maya":
            single_UniversalToolUI = UniversalToolUI(parentWin, mode)
        else:
            single_UniversalToolUI = UniversalToolUI()
        # extra note: in Maya () for no parent; (parentWin,0) for extra mode input
    single_UniversalToolUI.show()
    ui = single_UniversalToolUI
    
    # template 2 - allow loading multiple windows of same UI in Maya
    '''
    if hostMode == "maya":
        ui = UniversalToolUI(parentWin)
        ui.show()
    else:
        
    # extra note: in Maya () for no parent; (parentWin,0) for extra mode input
    
    '''
    
    # loop app object for certain host
    if hostMode in ("desktop"):
        sys.exit(app.exec_())
    
    return ui 
Example #28
Source File: universal_tool_template_v8.1.py    From universal_tool_template.py with MIT License 4 votes vote down vote up
def main(mode=0):
    # get parent window in Maya
    parentWin = None
    if hostMode == "maya":
        if qtMode in (0,2): # pyside
            parentWin = shiboken.wrapInstance(long(mui.MQtUtil.mainWindow()), QtWidgets.QWidget)
        elif qtMode in (1,3): # PyQt
            parentWin = sip.wrapinstance(long(mui.MQtUtil.mainWindow()), QtCore.QObject)
    # create app object for certain host
    app = None
    if hostMode in ("desktop", "blender"):
        app = QtWidgets.QApplication(sys.argv)
    
    #--------------------------
    # ui instance
    #--------------------------
    # template 1 - Keep only one copy of windows ui in Maya
    global single_UniversalToolUI
    if single_UniversalToolUI is None:
        if hostMode == "maya":
            single_UniversalToolUI = UniversalToolUI(parentWin, mode)
        else:
            single_UniversalToolUI = UniversalToolUI()
        # extra note: in Maya () for no parent; (parentWin,0) for extra mode input
    single_UniversalToolUI.show()
    ui = single_UniversalToolUI
    
    # template 2 - allow loading multiple windows of same UI in Maya
    '''
    if hostMode == "maya":
        ui = UniversalToolUI(parentWin)
        ui.show()
    else:
        
    # extra note: in Maya () for no parent; (parentWin,0) for extra mode input
    
    '''
    
    # loop app object for certain host
    if hostMode in ("desktop"):
        sys.exit(app.exec_())
    
    return ui 
Example #29
Source File: UITranslator.py    From universal_tool_template.py with MIT License 4 votes vote down vote up
def main(mode=0):
    # get parent window in Maya
    parentWin = None
    if hostMode == "maya":
        if qtMode in (0,2): # pyside
            parentWin = shiboken.wrapInstance(long(mui.MQtUtil.mainWindow()), QtWidgets.QWidget)
        elif qtMode in (1,3): # PyQt
            parentWin = sip.wrapinstance(long(mui.MQtUtil.mainWindow()), QtCore.QObject)
    # create app object for certain host
    app = None
    if hostMode in ("desktop", "blender"):
        app = QtWidgets.QApplication(sys.argv)
    
    #--------------------------
    # ui instance
    #--------------------------
    # template 1 - Keep only one copy of windows ui in Maya
    global single_UITranslator
    if single_UITranslator is None:
        if hostMode == "maya":
            single_UITranslator = UITranslator(parentWin, mode)
        else:
            single_UITranslator = UITranslator()
        # extra note: in Maya () for no parent; (parentWin,0) for extra mode input
    single_UITranslator.show()
    ui = single_UITranslator
    
    # template 2 - allow loading multiple windows of same UI in Maya
    '''
    if hostMode == "maya":
        ui = UITranslator(parentWin)
        ui.show()
    else:
        
    # extra note: in Maya () for no parent; (parentWin,0) for extra mode input
    
    '''
    
    # loop app object for certain host
    if hostMode in ("desktop"):
        sys.exit(app.exec_())
    
    return ui