Python PySide.QtUiTools.QUiLoader() Examples

The following are 21 code examples of PySide.QtUiTools.QUiLoader(). 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 PySide.QtUiTools , or try the search function .
Example #1
Source File: Qt.py    From pipeline with MIT License 6 votes vote down vote up
def _pyside2():
    import PySide2
    from PySide2 import QtGui, QtWidgets, QtCore, QtUiTools

    _remap(QtCore, "QStringListModel", QtGui.QStringListModel)

    _add(PySide2, "__binding__", PySide2.__name__)
    _add(PySide2, "load_ui", lambda fname: QtUiTools.QUiLoader().load(fname))
    _add(PySide2, "translate", lambda context, sourceText, disambiguation, n: (
        QtCore.QCoreApplication(context, sourceText,
                                disambiguation, None, n)))
    _add(PySide2,
         "setSectionResizeMode",
         QtWidgets.QHeaderView.setSectionResizeMode)

    _maintain_backwards_compatibility(PySide2)

    return PySide2 
Example #2
Source File: Qt.py    From CNCGToolKit with MIT License 6 votes vote down vote up
def _pyside_loadui(fname):
    '''
    this function is for PySide load_ui bug when there are custom widgets in the ui file
    '''
    import PySide.QtUiTools as QtUiTools
    import importlib
    loader = QtUiTools.QUiLoader()
    # get custom_widget
    with open(fname) as ui_file:
        all_xml = ui_file.read()
        custom_wgt_xmls = re.findall(r'<customwidget>.*?</customwidget>', all_xml, re.S)
        for cus_wgt_xml in custom_wgt_xmls:
            class_search = re.search(r"<class>(.*?)</class>", cus_wgt_xml, re.S)
            class_name = class_search.group(1)
            module_search = re.search(r"<header.*>(.*?)</header>", cus_wgt_xml, re.S)
            module_name = module_search.group(1).replace("/", ".")
            # import and register
            module = importlib.import_module(module_name)
            loader.registerCustomWidget(getattr(module, class_name))
    return loader.load(fname) 
Example #3
Source File: Qt.py    From pyblish-maya with GNU Lesser General Public License v3.0 6 votes vote down vote up
def _pyside2():
    import PySide2
    from PySide2 import QtGui, QtWidgets, QtCore, QtUiTools

    _remap(QtCore, "QStringListModel", QtGui.QStringListModel)

    _add(QtCompat, "__binding__", PySide2.__name__)
    _add(QtCompat, "__binding_version__", PySide2.__version__)
    _add(QtCompat, "__qt_version__", PySide2.QtCore.qVersion())
    _add(QtCompat, "load_ui", lambda fname: QtUiTools.QUiLoader().load(fname))

    _add(QtCompat, "setSectionResizeMode",
         QtWidgets.QHeaderView.setSectionResizeMode)

    _add(QtCompat, "translate", QtCore.QCoreApplication.translate)

    _maintain_backwards_compatibility(PySide2)

    return PySide2 
Example #4
Source File: Qt.py    From uExport with zlib License 6 votes vote down vote up
def _pyside2():
    import PySide2
    from PySide2 import QtGui, QtWidgets, QtCore, QtUiTools

    _remap(QtCore, "QStringListModel", QtGui.QStringListModel)

    _add(PySide2, "__binding__", PySide2.__name__)
    _add(PySide2, "load_ui", lambda fname: QtUiTools.QUiLoader().load(fname))
    _add(PySide2, "translate", lambda context, sourceText, disambiguation, n: (
        QtCore.QCoreApplication(context, sourceText,
                                disambiguation, None, n)))
    _add(PySide2,
         "setSectionResizeMode",
         QtWidgets.QHeaderView.setSectionResizeMode)

    _maintain_backwards_compatibility(PySide2)

    return PySide2 
Example #5
Source File: BlendTransforms.py    From BlendTransforms with The Unlicense 6 votes vote down vote up
def __init__( self, parent = BT_GetMayaWindow() ):
        super(BT_UIForm, self).__init__(parent)

        uicPath = BT_FindUIFile()

        if not uicPath:
            return None

        self.ui = None
        if BT_MayaVersionNumber < 2014:
            self.ui = uic.loadUi(uicPath, self)
        else:
            loader = QtUiTools.QUiLoader()
            self.ui = loader.load(uicPath, self)

        self.ui.loadSelectedButton.clicked.connect(self.loadSelectedSet)
        self.ui.connectButton.clicked.connect(self.connectSetup)
        self.ui.disconnectButton.clicked.connect(self.disconnectSetup)
        self.ui.setToBaseButton.clicked.connect(self.setToBasePose)
        self.ui.setToSelectedButton.clicked.connect(self.setToPose)
        self.ui.addPoseButton.clicked.connect(self.addPose)
        self.ui.deletePoseButton.clicked.connect(self.deletePose)
        self.ui.updateSelectedButton.clicked.connect(self.updatePose)

        unitResult = BT_SetUnits()
        if unitResult:
            QtGui.QMessageBox.warning(self, "Blend Transforms", "Units set to centimetres.", "Okay")

        self.ui.show() 
Example #6
Source File: IDASynergy.py    From IDASynergy with MIT License 5 votes vote down vote up
def __init__(self):
            super(IDASynergyChooserUI, self).__init__()
            self.loader = QUiLoader()
            self.initUI()
            self.result = None 
Example #7
Source File: QtVariant.py    From calfem-python with MIT License 5 votes vote down vote up
def QtLoadUI(uifile):
        from PySide import QtUiTools
        loader = QtUiTools.QUiLoader()
        uif = QtCore.QFile(uifile)
        uif.open(QtCore.QFile.ReadOnly)
        result = loader.load(uif)
        uif.close()
        return result 
Example #8
Source File: Toolbox.py    From CANalyzat0r with GNU General Public License v3.0 5 votes vote down vote up
def widgetFromUIFile(filePath):
        """
        Reads an ``.ui`` file and creates a new widget object from it.

        :param filePath: Where to find the ``.ui`` file
        :return: The new created widget
        """

        loader = QUiLoader()
        UIFile = QFile(filePath)
        UIFile.open(QFile.ReadOnly)
        widget = loader.load(UIFile)
        UIFile.close()
        return widget 
Example #9
Source File: Qt.py    From pyblish-maya with GNU Lesser General Public License v3.0 5 votes vote down vote up
def _pyside():
    import PySide
    from PySide import QtGui, QtCore, QtUiTools

    _remap(PySide, "QtWidgets", QtGui)
    _remap(QtCore, "QSortFilterProxyModel", QtGui.QSortFilterProxyModel)
    _remap(QtCore, "QStringListModel", QtGui.QStringListModel)
    _remap(QtCore, "QItemSelection", QtGui.QItemSelection)
    _remap(QtCore, "QItemSelectionModel", QtGui.QItemSelectionModel)
    _remap(QtCore, "QAbstractProxyModel", QtGui.QAbstractProxyModel)

    try:
        from PySide import QtWebKit
        _remap(PySide, "QtWebKitWidgets", QtWebKit)
    except ImportError:
        "QtWebkit is optional in Qt, therefore might not be available"

    _add(QtCompat, "__binding__", PySide.__name__)
    _add(QtCompat, "__binding_version__", PySide.__version__)
    _add(QtCompat, "__qt_version__", PySide.QtCore.qVersion())
    _add(QtCompat, "load_ui", lambda fname: QtUiTools.QUiLoader().load(fname))
    _add(QtCompat, "setSectionResizeMode", QtGui.QHeaderView.setResizeMode)

    _add(QtCompat, "translate",
         lambda context, sourceText, disambiguation, n:
         QtCore.QCoreApplication.translate(context,
                                           sourceText,
                                           disambiguation,
                                           QtCore.QCoreApplication.CodecForTr,
                                           n))

    _maintain_backwards_compatibility(PySide)

    return PySide 
Example #10
Source File: Qt.py    From pipeline with MIT License 5 votes vote down vote up
def _pyside():
    import PySide
    from PySide import QtGui, QtCore, QtUiTools

    _remap(PySide, "QtWidgets", QtGui)
    _remap(QtCore, "QSortFilterProxyModel", QtGui.QSortFilterProxyModel)
    _remap(QtCore, "QStringListModel", QtGui.QStringListModel)
    _remap(QtCore, "QItemSelection", QtGui.QItemSelection)
    _remap(QtCore, "QItemSelectionModel", QtGui.QItemSelectionModel)
    _remap(QtCore, "QAbstractProxyModel", QtGui.QAbstractProxyModel)

    try:
        from PySide import QtWebKit
        _remap(PySide, "QtWebKitWidgets", QtWebKit)
    except ImportError:
        # QtWebkit is optional in Qt, therefore might not be available
        pass

    _add(PySide, "__binding__", PySide.__name__)
    _add(PySide, "load_ui", lambda fname: QtUiTools.QUiLoader().load(fname))
    _add(PySide, "translate", lambda context, sourceText, disambiguation, n: (
        QtCore.QCoreApplication(context, sourceText,
                                disambiguation, None, n)))
    _add(PySide, "setSectionResizeMode", QtGui.QHeaderView.setResizeMode)

    _maintain_backwards_compatibility(PySide)

    return PySide 
Example #11
Source File: Qt.py    From uExport with zlib License 5 votes vote down vote up
def _pyside():
    import PySide
    from PySide import QtGui, QtCore, QtUiTools

    _remap(PySide, "QtWidgets", QtGui)
    _remap(QtCore, "QSortFilterProxyModel", QtGui.QSortFilterProxyModel)
    _remap(QtCore, "QStringListModel", QtGui.QStringListModel)
    _remap(QtCore, "QItemSelection", QtGui.QItemSelection)
    _remap(QtCore, "QItemSelectionModel", QtGui.QItemSelectionModel)
    _remap(QtCore, "QAbstractProxyModel", QtGui.QAbstractProxyModel)

    try:
        from PySide import QtWebKit
        _remap(PySide, "QtWebKitWidgets", QtWebKit)
    except ImportError:
        # QtWebkit is optional in Qt, therefore might not be available
        pass

    _add(PySide, "__binding__", PySide.__name__)
    _add(PySide, "load_ui", lambda fname: QtUiTools.QUiLoader().load(fname))
    _add(PySide, "translate", lambda context, sourceText, disambiguation, n: (
        QtCore.QCoreApplication(context, sourceText,
                                disambiguation, None, n)))
    _add(PySide, "setSectionResizeMode", QtGui.QHeaderView.setResizeMode)

    _maintain_backwards_compatibility(PySide)

    return PySide 
Example #12
Source File: _compat.py    From mGui with MIT License 5 votes vote down vote up
def _pyside_load_ui(fyle, parent=None):
    from PySide.QtUiTools import QUiLoader
    loader = QUiLoader()
    return loader.load(fyle, parent) 
Example #13
Source File: _compat.py    From mGui with MIT License 5 votes vote down vote up
def _pyside2_load_ui(fyle, parent=None):
    from PySide2.QtUiTools import QUiLoader
    loader = QUiLoader()
    return loader.load(fyle, parent) 
Example #14
Source File: BlendTransforms.py    From BlendTransforms with The Unlicense 5 votes vote down vote up
def __init__( self, parent = BT_GetMayaWindow() ):
        super(BT_UIForm, self).__init__(parent)

        uicPath = BT_FindUIFile()

        if not uicPath:
            return None

        self.ui = None
        if BT_MayaVersionNumber < 2014:
            self.ui = uic.loadUi(uicPath, self)
        else:
            loader = QtUiTools.QUiLoader()
            self.ui = loader.load(uicPath, self)

        self.ui.loadSelectedButton.clicked.connect(self.loadSelectedSet)
        self.ui.connectButton.clicked.connect(self.connectSetup)
        self.ui.disconnectButton.clicked.connect(self.disconnectSetup)
        self.ui.setToBaseButton.clicked.connect(self.setToBasePose)
        self.ui.setToSelectedButton.clicked.connect(self.setToPose)
        self.ui.addPoseButton.clicked.connect(self.addPose)
        self.ui.deletePoseButton.clicked.connect(self.deletePose)
        self.ui.updateSelectedButton.clicked.connect(self.updatePose)

        unitResult = BT_SetUnits()
        if unitResult:
            QtGui.QMessageBox.warning(self, "Blend Transforms", "Units set to centimetres.", "Okay")

        self.ui.show() 
Example #15
Source File: IDASynergy.py    From IDASynergy with MIT License 5 votes vote down vote up
def __init__(self):
            super(IDASynergyWaitUI, self).__init__()
            self.loader = QUiLoader()
            self.initUI() 
Example #16
Source File: IDASynergy.py    From IDASynergy with MIT License 5 votes vote down vote up
def __init__(self):
            super(IDASynergyLogUI, self).__init__()
            self.loader = QUiLoader()
            self.initUI() 
Example #17
Source File: IDASynergy.py    From IDASynergy with MIT License 5 votes vote down vote up
def __init__(self, cb_ok, cb_fail):
            super(IDASynergyCommitUI, self).__init__()
            self.loader = QUiLoader()
            self.initUI()
            self.ui.buttonBox.accepted.connect(cb_ok)
            self.ui.buttonBox.rejected.connect(cb_fail) 
Example #18
Source File: IDASynergy.py    From IDASynergy with MIT License 5 votes vote down vote up
def __init__(self, cb_ok, cb_fail): 
            super(IDASynergyConfigUI, self).__init__()
            self.loader = QUiLoader()
            self.initUI()
            self.ui.buttonBox.accepted.connect(cb_ok)
            self.ui.buttonBox.rejected.connect(cb_fail) 
Example #19
Source File: baseTab.py    From DeformationLearningSolver with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, parent=None):
        super(BaseTab, self).__init__(parent)
        #self.parent = parent
        #loader = QUiLoader()
        #f = QFile(uifile)
        #f.open(QFile.ReadOnly)
        #widget = loader.load(f, self)
        #f.close()
    
        #layout = QVBoxLayout()
        #layout.addWidget(widget)
        #self.setLayout(layout)
        #utils.loadUi(uifile)
    
    #---------------------------------------------------------------------- 
Example #20
Source File: BlendTransforms.py    From BlendTransforms with The Unlicense 5 votes vote down vote up
def __init__( self, parent = BT_GetMayaWindow() ):
        super(BT_UIForm, self).__init__(parent)

        uicPath = BT_FindUIFile()

        if not uicPath:
            return None

        self.ui = None
        if BT_MayaVersionNumber < 2014:
            self.ui = uic.loadUi(uicPath, self)
        else:
            loader = QtUiTools.QUiLoader()
            self.ui = loader.load(uicPath, self)

        self.ui.loadSelectedButton.clicked.connect(self.loadSelectedSet)
        self.ui.connectButton.clicked.connect(self.connectSetup)
        self.ui.disconnectButton.clicked.connect(self.disconnectSetup)
        self.ui.setToBaseButton.clicked.connect(self.setToBasePose)
        self.ui.setToSelectedButton.clicked.connect(self.setToPose)
        self.ui.addPoseButton.clicked.connect(self.addPose)
        self.ui.deletePoseButton.clicked.connect(self.deletePose)
        self.ui.updateSelectedButton.clicked.connect(self.updatePose)

        unitResult = BT_SetUnits()
        if unitResult:
            QtGui.QMessageBox.warning(self, "Blend Transforms", "Units set to centimetres.", "Okay")

        self.ui.show() 
Example #21
Source File: BlendTransforms.py    From BlendTransforms with The Unlicense 5 votes vote down vote up
def __init__( self, parent = BT_GetMayaWindow() ):
        super(BT_UIForm, self).__init__(parent)

        uicPath = BT_FindUIFile()

        if not uicPath:
            return None

        self.ui = None
        if BT_MayaVersionNumber < 2014:
            self.ui = uic.loadUi(uicPath, self)
        else:
            loader = QtUiTools.QUiLoader()
            self.ui = loader.load(uicPath, self)

        self.ui.loadSelectedButton.clicked.connect(self.loadSelectedSet)
        self.ui.connectButton.clicked.connect(self.connectSetup)
        self.ui.disconnectButton.clicked.connect(self.disconnectSetup)
        self.ui.setToBaseButton.clicked.connect(self.setToBasePose)
        self.ui.setToSelectedButton.clicked.connect(self.setToPose)
        self.ui.addPoseButton.clicked.connect(self.addPose)
        self.ui.deletePoseButton.clicked.connect(self.deletePose)
        self.ui.updateSelectedButton.clicked.connect(self.updatePose)

        unitResult = BT_SetUnits()
        if unitResult:
            QtGui.QMessageBox.warning(self, "Blend Transforms", "Units set to centimetres.", "Okay")

        self.ui.show()