當前位置: 首頁>>代碼示例>>Python>>正文


Python QtCore.pyqtSlot方法代碼示例

本文整理匯總了Python中PyQt5.QtCore.pyqtSlot方法的典型用法代碼示例。如果您正苦於以下問題:Python QtCore.pyqtSlot方法的具體用法?Python QtCore.pyqtSlot怎麽用?Python QtCore.pyqtSlot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt5.QtCore的用法示例。


在下文中一共展示了QtCore.pyqtSlot方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _fillMarkerContextMenu_

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import pyqtSlot [as 別名]
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) 
開發者ID:matzman666,項目名稱:PyPipboyApp,代碼行數:27,代碼來源:globalmapwidget.py

示例2: _setup_pyqt5

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import pyqtSlot [as 別名]
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 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:19,代碼來源:qt_compat.py

示例3: progressStarted

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import pyqtSlot [as 別名]
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() 
開發者ID:pyrocko,項目名稱:kite,代碼行數:27,代碼來源:spool.py

示例4: _markerContextMenuEvent_

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import pyqtSlot [as 別名]
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()) 
開發者ID:matzman666,項目名稱:PyPipboyApp,代碼行數:22,代碼來源:marker.py

示例5: pyqtSlot

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import pyqtSlot [as 別名]
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 
開發者ID:Ultimaker,項目名稱:Uranium,代碼行數:24,代碼來源:FlameProfiler.py

示例6: _pyqt5

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import pyqtSlot [as 別名]
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 
開發者ID:chrisevans3d,項目名稱:uExport,代碼行數:22,代碼來源:Qt.py

示例7: __init__

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import pyqtSlot [as 別名]
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可以調用 
開發者ID:PyQt5,項目名稱:PyQt,代碼行數:23,代碼來源:JsSignals.py

示例8: import_pyqt5

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import pyqtSlot [as 別名]
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 
開發者ID:holzschu,項目名稱:Carnets,代碼行數:25,代碼來源:qt_loaders.py

示例9: _js_slot

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import pyqtSlot [as 別名]
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 
開發者ID:qutebrowser,項目名稱:qutebrowser,代碼行數:29,代碼來源:pac.py

示例10: import_pyqt4

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import pyqtSlot [as 別名]
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 
開發者ID:fabioz,項目名稱:PyDev.Debugger,代碼行數:37,代碼來源:qt_loaders.py

示例11: import_pyqt5

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import pyqtSlot [as 別名]
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 
開發者ID:fabioz,項目名稱:PyDev.Debugger,代碼行數:15,代碼來源:qt_loaders.py

示例12: asyncSlot

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import pyqtSlot [as 別名]
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 
開發者ID:gmarull,項目名稱:asyncqt,代碼行數:11,代碼來源:__init__.py

示例13: addTimeSlider

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import pyqtSlot [as 別名]
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) 
開發者ID:pyrocko,項目名稱:kite,代碼行數:38,代碼來源:spool.py

示例14: import_pyqt4

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import pyqtSlot [as 別名]
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 
開發者ID:luckystarufo,項目名稱:pySINDy,代碼行數:37,代碼來源:qt_loaders.py

示例15: rowCount

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import pyqtSlot [as 別名]
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 
開發者ID:Ultimaker,項目名稱:Uranium,代碼行數:12,代碼來源:ListModel.py


注:本文中的PyQt5.QtCore.pyqtSlot方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。