Python PyQt5.QtCore.pyqtSlot() Examples

The following are 30 code examples for showing how to use PyQt5.QtCore.pyqtSlot(). These examples are extracted from open source projects. 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 check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module PyQt5.QtCore , or try the search function .

Example 1
Project: Mastering-Elasticsearch-7.0   Author: PacktPublishing   File: qt_compat.py    License: MIT License 7 votes vote down vote up
def _setup_pyqt5():
    global QtCore, QtGui, QtWidgets, __version__, is_pyqt5, _getSaveFileName

    if QT_API == QT_API_PYQT5:
        from PyQt5 import QtCore, QtGui, QtWidgets
        __version__ = QtCore.PYQT_VERSION_STR
        QtCore.Signal = QtCore.pyqtSignal
        QtCore.Slot = QtCore.pyqtSlot
        QtCore.Property = QtCore.pyqtProperty
    elif QT_API == QT_API_PYSIDE2:
        from PySide2 import QtCore, QtGui, QtWidgets, __version__
    else:
        raise ValueError("Unexpected value for the 'backend.qt5' rcparam")
    _getSaveFileName = QtWidgets.QFileDialog.getSaveFileName

    def is_pyqt5():
        return True 
Example 2
Project: GraphicDesignPatternByPython   Author: Relph1119   File: qt_compat.py    License: MIT License 7 votes vote down vote up
def _setup_pyqt5():
    global QtCore, QtGui, QtWidgets, __version__, is_pyqt5, _getSaveFileName

    if QT_API == QT_API_PYQT5:
        from PyQt5 import QtCore, QtGui, QtWidgets
        __version__ = QtCore.PYQT_VERSION_STR
        QtCore.Signal = QtCore.pyqtSignal
        QtCore.Slot = QtCore.pyqtSlot
        QtCore.Property = QtCore.pyqtProperty
    elif QT_API == QT_API_PYSIDE2:
        from PySide2 import QtCore, QtGui, QtWidgets, __version__
    else:
        raise ValueError("Unexpected value for the 'backend.qt5' rcparam")
    _getSaveFileName = QtWidgets.QFileDialog.getSaveFileName

    def is_pyqt5():
        return True 
Example 3
Project: kite   Author: pyrocko   File: spool.py    License: GNU General Public License v3.0 6 votes vote down vote up
def progressStarted(self, args):
        if self.progress.isVisible():
            return

        nargs = len(args)

        text = args[0]
        maximum = 0 if nargs < 2 else args[1]
        progress_func = None if nargs < 3 else args[2]

        self.progress.setWindowTitle('Processing...')
        self.progress.setLabelText(text)
        self.progress.setMaximum(maximum)
        self.progress.setValue(0)

        @QtCore.pyqtSlot()
        def updateProgress():
            if progress_func:
                self.progress.setValue(progress_func())

        self.progress_timer = QtCore.QTimer()
        self.progress_timer.timeout.connect(updateProgress)
        self.progress_timer.start(250)

        self.progress.show() 
Example 4
Project: PyPipboyApp   Author: matzman666   File: marker.py    License: GNU General Public License v3.0 6 votes vote down vote up
def _markerContextMenuEvent_(self, event):
        menu = QtWidgets.QMenu(self.view)
        self._fillMarkerContextMenu_(event, menu)
        if self.labelItem and not self.labelAlwaysVisible:
            @QtCore.pyqtSlot(bool)
            def _toggleStickyLabel(value):
                if self.uid != None:
                    settingPath = 'globalmapwidget/stickylabels2/'
                    if (value):
                        self.widget._app.settings.setValue(settingPath+self.uid, int(value))
                    else:
                        self.widget._app.settings.beginGroup(settingPath);
                        self.widget._app.settings.remove(self.uid); 
                        self.widget._app.settings.endGroup();
                self.setStickyLabel(value)
            ftaction = menu.addAction('Sticky Label')
            ftaction.toggled.connect(_toggleStickyLabel)
            ftaction.setCheckable(True)
            ftaction.setChecked(self.stickyLabel)
        menu.exec(event.screenPos()) 
Example 5
Project: PyPipboyApp   Author: matzman666   File: globalmapwidget.py    License: GNU General Public License v3.0 6 votes vote down vote up
def _fillMarkerContextMenu_(self, event, menu):
        @QtCore.pyqtSlot(bool)
        def _markAsCollected(value):
            if self.itemFormID != None:
                collectedcollectablesSettingsPath =\
                    self.widget.characterDataManager.playerDataPath + self.widget.characterDataManager.collectedcollectablesuffix
                index = self.widget._app.settings.value(collectedcollectablesSettingsPath, None)
                if index == None:
                    index = []
                tmp = str(int(self.itemFormID,16))
                if (value):
                    if tmp not in index:
                        index = list(set(index)) # remove duplicates
                        index.append(tmp)
                        self.widget._app.settings.setValue(collectedcollectablesSettingsPath, index)
                else:
                    if tmp in index:
                        index = list(set(index)) # remove duplicates
                        index.remove(tmp)
                        self.widget._app.settings.setValue(collectedcollectablesSettingsPath, index)
            self.setCollected(value)
        ftaction = menu.addAction('Mark as Collected')
        ftaction.triggered.connect(_markAsCollected)
        ftaction.setCheckable(True)
        ftaction.setChecked(self.collected) 
Example 6
Project: Uranium   Author: Ultimaker   File: FlameProfiler.py    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
def pyqtSlot(*args, **kwargs) -> Callable[..., Any]:
    """Drop in replacement for PyQt5's pyqtSlot decorator which records profiling information.

    See the PyQt5 documentation for information about pyqtSlot.
    """

    if enabled():
        def wrapIt(function):
            @functools.wraps(function)
            def wrapped(*args2, **kwargs2):
                if isRecordingProfile():
                    with profileCall("[SLOT] "+ function.__qualname__):
                        return function(*args2, **kwargs2)
                else:
                    return function(*args2, **kwargs2)

            return pyqt5PyqtSlot(*args, **kwargs)(wrapped)
        return wrapIt
    else:
        def dontWrapIt(function):
            return pyqt5PyqtSlot(*args, **kwargs)(function)
        return dontWrapIt 
Example 7
Project: uExport   Author: chrisevans3d   File: Qt.py    License: zlib License 6 votes vote down vote up
def _pyqt5():
    import PyQt5.Qt
    from PyQt5 import QtCore, QtWidgets, uic

    _remap(QtCore, "Signal", QtCore.pyqtSignal)
    _remap(QtCore, "Slot", QtCore.pyqtSlot)
    _remap(QtCore, "Property", QtCore.pyqtProperty)

    _add(PyQt5, "__binding__", PyQt5.__name__)
    _add(PyQt5, "load_ui", lambda fname: uic.loadUi(fname))
    _add(PyQt5, "translate", lambda context, sourceText, disambiguation, n: (
        QtCore.QCoreApplication(context, sourceText,
                                disambiguation, n)))
    _add(PyQt5,
         "setSectionResizeMode",
         QtWidgets.QHeaderView.setSectionResizeMode)

    _maintain_backwards_compatibility(PyQt5)

    return PyQt5 
Example 8
Project: PyQt   Author: PyQt5   File: JsSignals.py    License: GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, *args, **kwargs):
        super(WebEngineView, self).__init__(*args, **kwargs)
        self.initSettings()
        self.channel = QWebChannel(self)
        # 把自身对象传递进去
        self.channel.registerObject('Bridge', self)
        # 设置交互接口
        self.page().setWebChannel(self.channel)

        # START #####以下代码可能是在5.6 QWebEngineView刚出来时的bug,必须在每次加载页面的时候手动注入
        #### 也有可能是跳转页面后就失效了,需要手动注入,有没有修复具体未测试

#         self.page().loadStarted.connect(self.onLoadStart)
#         self._script = open('Data/qwebchannel.js', 'rb').read().decode()

#     def onLoadStart(self):
#         self.page().runJavaScript(self._script)

        # END ###########################

    # 注意pyqtSlot用于把该函数暴露给js可以调用 
Example 9
Project: coffeegrindsize   Author: jgagneastro   File: qt_compat.py    License: MIT License 6 votes vote down vote up
def _setup_pyqt5():
    global QtCore, QtGui, QtWidgets, __version__, is_pyqt5, _getSaveFileName

    if QT_API == QT_API_PYQT5:
        from PyQt5 import QtCore, QtGui, QtWidgets
        __version__ = QtCore.PYQT_VERSION_STR
        QtCore.Signal = QtCore.pyqtSignal
        QtCore.Slot = QtCore.pyqtSlot
        QtCore.Property = QtCore.pyqtProperty
    elif QT_API == QT_API_PYSIDE2:
        from PySide2 import QtCore, QtGui, QtWidgets, __version__
    else:
        raise ValueError("Unexpected value for the 'backend.qt5' rcparam")
    _getSaveFileName = QtWidgets.QFileDialog.getSaveFileName

    def is_pyqt5():
        return True 
Example 10
Project: CogAlg   Author: boris-kz   File: qt_compat.py    License: MIT License 6 votes vote down vote up
def _setup_pyqt5():
    global QtCore, QtGui, QtWidgets, __version__, is_pyqt5, _getSaveFileName

    if QT_API == QT_API_PYQT5:
        from PyQt5 import QtCore, QtGui, QtWidgets
        __version__ = QtCore.PYQT_VERSION_STR
        QtCore.Signal = QtCore.pyqtSignal
        QtCore.Slot = QtCore.pyqtSlot
        QtCore.Property = QtCore.pyqtProperty
    elif QT_API == QT_API_PYSIDE2:
        from PySide2 import QtCore, QtGui, QtWidgets, __version__
    else:
        raise ValueError("Unexpected value for the 'backend.qt5' rcparam")
    _getSaveFileName = QtWidgets.QFileDialog.getSaveFileName

    def is_pyqt5():
        return True 
Example 11
Project: Carnets   Author: holzschu   File: qt_loaders.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def import_pyqt5():
    """
    Import PyQt5

    ImportErrors rasied within this function are non-recoverable
    """

    from PyQt5 import QtCore, QtSvg, QtWidgets, QtGui, QtPrintSupport

    import sip

    # Alias PyQt-specific functions for PySide compatibility.
    QtCore.Signal = QtCore.pyqtSignal
    QtCore.Slot = QtCore.pyqtSlot

    # Join QtGui and QtWidgets for Qt4 compatibility.
    QtGuiCompat = types.ModuleType('QtGuiCompat')
    QtGuiCompat.__dict__.update(QtGui.__dict__)
    QtGuiCompat.__dict__.update(QtWidgets.__dict__)
    QtGuiCompat.__dict__.update(QtPrintSupport.__dict__)

    api = QT_API_PYQT5
    return QtCore, QtGuiCompat, QtSvg, api 
Example 12
Project: twitter-stock-recommendation   Author: alvarobartt   File: qt_compat.py    License: MIT License 6 votes vote down vote up
def _setup_pyqt5():
    global QtCore, QtGui, QtWidgets, __version__, is_pyqt5, _getSaveFileName

    if QT_API == QT_API_PYQT5:
        from PyQt5 import QtCore, QtGui, QtWidgets
        __version__ = QtCore.PYQT_VERSION_STR
        QtCore.Signal = QtCore.pyqtSignal
        QtCore.Slot = QtCore.pyqtSlot
        QtCore.Property = QtCore.pyqtProperty
    elif QT_API == QT_API_PYSIDE2:
        from PySide2 import QtCore, QtGui, QtWidgets, __version__
    else:
        raise ValueError("Unexpected value for the 'backend.qt5' rcparam")
    _getSaveFileName = QtWidgets.QFileDialog.getSaveFileName

    def is_pyqt5():
        return True 
Example 13
Project: qutebrowser   Author: qutebrowser   File: pac.py    License: GNU General Public License v3.0 5 votes vote down vote up
def _js_slot(*args):
    """Wrap a methods as a JavaScript function.

    Register a PACContext method as a JavaScript function, and catch
    exceptions returning them as JavaScript Error objects.

    Args:
        args: Types of method arguments.

    Return: Wrapped method.
    """
    def _decorator(method):
        @functools.wraps(method)
        def new_method(self, *args, **kwargs):
            """Call the underlying function."""
            try:
                return method(self, *args, **kwargs)
            except:
                e = str(sys.exc_info()[0])
                log.network.exception("PAC evaluation error")
                # pylint: disable=protected-access
                return self._error_con.callAsConstructor([e])
                # pylint: enable=protected-access

        deco = pyqtSlot(*args, result=QJSValue)  # type: ignore[arg-type]
        return deco(new_method)
    return _decorator 
Example 14
Project: pipeline   Author: liorbenhorin   File: Qt.py    License: MIT License 5 votes vote down vote up
def _pyqt5():
    import PyQt5.Qt
    from PyQt5 import QtCore, QtWidgets, uic

    _remap(QtCore, "Signal", QtCore.pyqtSignal)
    _remap(QtCore, "Slot", QtCore.pyqtSlot)
    _remap(QtCore, "Property", QtCore.pyqtProperty)

    _add(PyQt5, "__binding__", PyQt5.__name__)
    _add(PyQt5, "load_ui", lambda fname: uic.loadUi(fname))
    _add(PyQt5, "translate", lambda context, sourceText, disambiguation, n: (
        QtCore.QCoreApplication(context, sourceText,
                                disambiguation, n)))
    _add(PyQt5,
         "setSectionResizeMode",
         QtWidgets.QHeaderView.setSectionResizeMode)

    _maintain_backwards_compatibility(PyQt5)

    return PyQt5 
Example 15
Project: PyDev.Debugger   Author: fabioz   File: qt_loaders.py    License: Eclipse Public License 1.0 5 votes vote down vote up
def import_pyqt4(version=2):
    """
    Import PyQt4

    Parameters
    ----------
    version : 1, 2, or None
      Which QString/QVariant API to use. Set to None to use the system
      default

    ImportErrors raised within this function are non-recoverable
    """
    # The new-style string API (version=2) automatically
    # converts QStrings to Unicode Python strings. Also, automatically unpacks
    # QVariants to their underlying objects.
    import sip

    if version is not None:
        sip.setapi('QString', version)
        sip.setapi('QVariant', version)

    from PyQt4 import QtGui, QtCore, QtSvg

    if not check_version(QtCore.PYQT_VERSION_STR, '4.7'):
        raise ImportError("IPython requires PyQt4 >= 4.7, found %s" %
                          QtCore.PYQT_VERSION_STR)

    # Alias PyQt-specific functions for PySide compatibility.
    QtCore.Signal = QtCore.pyqtSignal
    QtCore.Slot = QtCore.pyqtSlot

    # query for the API version (in case version == None)
    version = sip.getapi('QString')
    api = QT_API_PYQTv1 if version == 1 else QT_API_PYQT
    return QtCore, QtGui, QtSvg, api 
Example 16
Project: PyDev.Debugger   Author: fabioz   File: qt_loaders.py    License: Eclipse Public License 1.0 5 votes vote down vote up
def import_pyqt5():
    """
    Import PyQt5

    ImportErrors raised within this function are non-recoverable
    """
    from PyQt5 import QtGui, QtCore, QtSvg

    # Alias PyQt-specific functions for PySide compatibility.
    QtCore.Signal = QtCore.pyqtSignal
    QtCore.Slot = QtCore.pyqtSlot

    return QtCore, QtGui, QtSvg, QT_API_PYQT5 
Example 17
Project: asyncqt   Author: gmarull   File: __init__.py    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
def asyncSlot(*args):
    """Make a Qt async slot run on asyncio loop."""
    def outer_decorator(fn):
        @Slot(*args)
        @functools.wraps(fn)
        def wrapper(*args, **kwargs):
            return asyncio.ensure_future(fn(*args, **kwargs))
        return wrapper
    return outer_decorator 
Example 18
Project: kite   Author: pyrocko   File: spool.py    License: GNU General Public License v3.0 5 votes vote down vote up
def addTimeSlider(self):
        stack = self.model.getScene()

        self.time_slider = QRangeSlider(self)
        self.time_slider.setMaximumHeight(50)

        slider_tmin = math.ceil(stack.tmin)
        slider_tmax = math.floor(stack.tmax)

        def datetime_formatter(value):
            return datetime.fromtimestamp(value).strftime('%Y-%m-%d')

        self.time_slider.setMin(slider_tmin)
        self.time_slider.setMax(slider_tmax)
        self.time_slider.setRange(slider_tmin, slider_tmax)
        self.time_slider.setFormatter(datetime_formatter)

        @QtCore.pyqtSlot(int)
        def changeTimeRange():
            tmin, tmax = self.time_slider.getRange()
            stack.set_time_range(tmin, tmax)

        self.time_slider.startValueChanged.connect(changeTimeRange)
        self.time_slider.endValueChanged.connect(changeTimeRange)

        self.dock_time_slider = QtGui.QDockWidget(
            'Displacement time series - range control', self)
        self.dock_time_slider.setWidget(self.time_slider)
        self.dock_time_slider.setFeatures(
            QtWidgets.QDockWidget.DockWidgetMovable)
        self.dock_time_slider.setAllowedAreas(
            QtCore.Qt.BottomDockWidgetArea |
            QtCore.Qt.TopDockWidgetArea)

        self.addDockWidget(
            QtCore.Qt.BottomDockWidgetArea, self.dock_time_slider) 
Example 19
Project: PyPipboyApp   Author: matzman666   File: globalmapwidget.py    License: GNU General Public License v3.0 5 votes vote down vote up
def _fillMarkerContextMenu_(self, event, menu):
        if self.pipValue:
            @QtCore.pyqtSlot()
            def _removeCustomMarker():
                self.datamanager.rpcRemoveCustomMarker()
            menu.addAction('Remove Marker', _removeCustomMarker) 
Example 20
Project: python3_ios   Author: holzschu   File: qt_compat.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _setup_pyqt5():
    global QtCore, QtGui, QtWidgets, __version__, is_pyqt5, _getSaveFileName

    if QT_API == QT_API_PYQT5:
        from PyQt5 import QtCore, QtGui, QtWidgets
        __version__ = QtCore.PYQT_VERSION_STR
        QtCore.Signal = QtCore.pyqtSignal
        QtCore.Slot = QtCore.pyqtSlot
        QtCore.Property = QtCore.pyqtProperty
    elif QT_API == QT_API_PYSIDE2:
        from PySide2 import QtCore, QtGui, QtWidgets, __version__
    else:
        raise ValueError("Unexpected value for the 'backend.qt5' rcparam")
    _getSaveFileName = QtWidgets.QFileDialog.getSaveFileName

    def is_pyqt5():
        return True 
Example 21
Project: pySINDy   Author: luckystarufo   File: qt_loaders.py    License: MIT License 5 votes vote down vote up
def import_pyqt4(version=2):
    """
    Import PyQt4

    Parameters
    ----------
    version : 1, 2, or None
      Which QString/QVariant API to use. Set to None to use the system
      default

    ImportErrors rasied within this function are non-recoverable
    """
    # The new-style string API (version=2) automatically
    # converts QStrings to Unicode Python strings. Also, automatically unpacks
    # QVariants to their underlying objects.
    import sip

    if version is not None:
        sip.setapi('QString', version)
        sip.setapi('QVariant', version)

    from PyQt4 import QtGui, QtCore, QtSvg

    if not check_version(QtCore.PYQT_VERSION_STR, '4.7'):
        raise ImportError("QtConsole requires PyQt4 >= 4.7, found %s" %
                          QtCore.PYQT_VERSION_STR)

    # Alias PyQt-specific functions for PySide compatibility.
    QtCore.Signal = QtCore.pyqtSignal
    QtCore.Slot = QtCore.pyqtSlot

    # query for the API version (in case version == None)
    version = sip.getapi('QString')
    api = QT_API_PYQTv1 if version == 1 else QT_API_PYQT
    return QtCore, QtGui, QtSvg, api 
Example 22
Project: pySINDy   Author: luckystarufo   File: qt_loaders.py    License: MIT License 5 votes vote down vote up
def import_pyqt5():
    """
    Import PyQt5

    ImportErrors rasied within this function are non-recoverable
    """

    from PyQt5 import QtCore, QtSvg, QtWidgets, QtGui, QtPrintSupport

    import sip

    # Alias PyQt-specific functions for PySide compatibility.
    QtCore.Signal = QtCore.pyqtSignal
    QtCore.Slot = QtCore.pyqtSlot

    # Join QtGui and QtWidgets for Qt4 compatibility.
    QtGuiCompat = types.ModuleType('QtGuiCompat')
    QtGuiCompat.__dict__.update(QtGui.__dict__)
    QtGuiCompat.__dict__.update(QtWidgets.__dict__)
    QtGuiCompat.__dict__.update(QtPrintSupport.__dict__)

    api = QT_API_PYQT5
    return QtCore, QtGuiCompat, QtSvg, api 
Example 23
Project: Uranium   Author: Ultimaker   File: ListModel.py    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
def rowCount(self, parent = None) -> int:
        """This function is necessary because it is abstract in QAbstractListModel.

        Under the hood, Qt will call this function when it needs to know how
        many items are in the model.
        This pyqtSlot will not be linked to the itemsChanged signal, so please
        use the normal count() function instead.
        """

        return self.count 
Example 24
Project: FeelUOwn   Author: feeluown   File: mpv_qtwidget_opengl.py    License: GNU General Public License v3.0 5 votes vote down vote up
def on_update(self, ctx=None):
        # HELP: maybeUpdate 中的部分逻辑需要在主线程中执行,
        # 而 QMetaObject.invokeMethod 似乎正好可以达到这个目标。
        # 我们将 maybe_update 标记为 pyqtSlot,这样才能正确的 invoke。
        QMetaObject.invokeMethod(self, 'maybe_update') 
Example 25
Project: FeelUOwn   Author: feeluown   File: mpv.py    License: GNU General Public License v3.0 5 votes vote down vote up
def on_update(self, ctx=None):
        # HELP: maybeUpdate 中的部分逻辑需要在主线程中执行,
        # 而 QMetaObject.invokeMethod 似乎正好可以达到这个目标。
        # 我们将 maybe_update 标记为 pyqtSlot,这样才能正确的 invoke。
        QMetaObject.invokeMethod(self, 'maybe_update') 
Example 26
Project: guppy-proxy   Author: roglew   File: proxy.py    License: MIT License 5 votes vote down vote up
def clean_thread(tid):
    @pyqtSlot()
    def clean():
        del ProxyThread.threads[tid]
    return clean 
Example 27
Project: pyblish-maya   Author: pyblish   File: Qt.py    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
def _pyqt5():
    import PyQt5.Qt
    from PyQt5 import QtCore, QtWidgets, uic

    _remap(QtCore, "Signal", QtCore.pyqtSignal)
    _remap(QtCore, "Slot", QtCore.pyqtSlot)
    _remap(QtCore, "Property", QtCore.pyqtProperty)

    _add(QtCompat, "__binding__", PyQt5.__name__)
    _add(QtCompat, "__binding_version__", PyQt5.QtCore.PYQT_VERSION_STR)
    _add(QtCompat, "__qt_version__", PyQt5.QtCore.QT_VERSION_STR)
    _add(QtCompat, "load_ui", lambda fname: uic.loadUi(fname))
    _add(QtCompat, "translate", QtCore.QCoreApplication.translate)
    _add(QtCompat, "setSectionResizeMode",
         QtWidgets.QHeaderView.setSectionResizeMode)

    _maintain_backwards_compatibility(PyQt5)

    return PyQt5 
Example 28
Project: PyQt   Author: PyQt5   File: JsSignals.py    License: GNU General Public License v3.0 5 votes vote down vote up
def _exposeInterface(self):
        """向Js暴露调用本地方法接口
        """
        self.page().mainFrame().addToJavaScriptWindowObject('Bridge', self)

    # 注意pyqtSlot用于把该函数暴露给js可以调用 
Example 29
Project: CNCGToolKit   Author: cineuse   File: Qt.py    License: MIT License 5 votes vote down vote up
def _pyqt5():
    import PyQt5.Qt
    from PyQt5 import QtCore, QtWidgets, uic

    _remap(QtCore, "Signal", QtCore.pyqtSignal)
    _remap(QtCore, "Slot", QtCore.pyqtSlot)
    _remap(QtCore, "Property", QtCore.pyqtProperty)

    _add(PyQt5, "__binding__", PyQt5.__name__)
    _add(PyQt5, "load_ui", lambda fname: uic.loadUi(fname))
    _add(PyQt5, "translate", lambda context, sourceText, disambiguation, n: (
        QtCore.QCoreApplication(context, sourceText,
                                disambiguation, n)))
    _add(PyQt5,
         "setSectionResizeMode",
         QtWidgets.QHeaderView.setSectionResizeMode)

    _maintain_backwards_compatibility(PyQt5)

    return PyQt5 
Example 30
Project: corrscope   Author: corrscope   File: model_bind.py    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
def model_setter(value_type: type) -> Callable[..., None]:
    @pyqtSlot(value_type)
    def set_model(self: BoundWidget, value):
        assert isinstance(value, value_type)
        try:
            self.pmodel[self.path] = value
        except CorrError:
            self.setPalette(self.error_palette)
        else:
            BoundWidget.set_model(self, value)
            self.setPalette(self.default_palette)

    return set_model