本文整理匯總了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)
示例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
示例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()
示例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())
示例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
示例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
示例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可以調用
示例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
示例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
示例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
示例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
示例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
示例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)
示例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
示例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