本文整理汇总了Python中PyQt5.QtCore.Qt.QueuedConnection方法的典型用法代码示例。如果您正苦于以下问题:Python Qt.QueuedConnection方法的具体用法?Python Qt.QueuedConnection怎么用?Python Qt.QueuedConnection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.Qt
的用法示例。
在下文中一共展示了Qt.QueuedConnection方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _processRequest
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import QueuedConnection [as 别名]
def _processRequest(self, request_data: "HttpRequestData") -> None:
now = time.time()
# Get the right http_method function and prepare arguments.
method = getattr(self._network_manager, request_data.http_method)
args = [request_data.request]
if request_data.data is not None:
args.append(request_data.data)
# Issue the request and add the reply into the currently in-progress requests set
reply = method(*args)
request_data.reply = reply
# Connect callback signals
reply.error.connect(lambda err, rd = request_data: self._onRequestError(rd, err), type = Qt.QueuedConnection)
reply.finished.connect(lambda rd = request_data: self._onRequestFinished(rd), type = Qt.QueuedConnection)
# Only connect download/upload progress callbacks when necessary to reduce CPU usage.
if request_data.download_progress_callback is not None or request_data.timeout is not None:
reply.downloadProgress.connect(request_data.onDownloadProgressCallback, type = Qt.QueuedConnection)
if request_data.upload_progress_callback is not None or request_data.timeout is not None:
reply.uploadProgress.connect(request_data.onUploadProgressCallback, type = Qt.QueuedConnection)
with self._request_lock:
self._requests_in_progress.add(request_data)
request_data.setStartTime(now)
示例2: moveEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import QueuedConnection [as 别名]
def moveEvent(self, event):
QMetaObject.invokeMethod(self, "_onWindowGeometryChanged", Qt.QueuedConnection)
示例3: resizeEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import QueuedConnection [as 别名]
def resizeEvent(self, event):
super().resizeEvent(event)
win_w = event.size().width() * self.devicePixelRatio()
win_h = event.size().height() * self.devicePixelRatio()
self._updateViewportGeometry(win_w, win_h)
QMetaObject.invokeMethod(self, "_onWindowGeometryChanged", Qt.QueuedConnection)
示例4: emit
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import QueuedConnection [as 别名]
def emit(self, *args):
assert len(self.args_types) == len(args)
cooked_args = [Q_ARG(t, v) for t, v in zip(self.args_types, args)]
QMetaObject.invokeMethod(self.qobj, self.signal_name, Qt.QueuedConnection, *cooked_args)
示例5: __init__
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import QueuedConnection [as 别名]
def __init__(self, window, uaclient):
self.window = window
self.uaclient = uaclient
self._handler = EventHandler()
self._subscribed_nodes = [] # FIXME: not really needed
self.model = QStandardItemModel()
self.window.ui.evView.setModel(self.model)
self.window.ui.actionSubscribeEvent.triggered.connect(self._subscribe)
self.window.ui.actionUnsubscribeEvents.triggered.connect(self._unsubscribe)
# context menu
self.window.addAction(self.window.ui.actionSubscribeEvent)
self.window.addAction(self.window.ui.actionUnsubscribeEvents)
self.window.addAction(self.window.ui.actionAddToGraph)
self._handler.event_fired.connect(self._update_event_model, type=Qt.QueuedConnection)
# accept drops
self.model.canDropMimeData = self.canDropMimeData
self.model.dropMimeData = self.dropMimeData
示例6: __init__
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import QueuedConnection [as 别名]
def __init__(self, *args, **kwargs):
super(Window, self).__init__(*args, **kwargs)
self.resize(400, 400)
layout = QVBoxLayout(self)
self.progressBar = QProgressBar(self)
layout.addWidget(self.progressBar)
Signals.updateProgress.connect(
self.progressBar.setValue, type=Qt.QueuedConnection)
QTimer.singleShot(2000, self.doStart)
示例7: run_on_ui_thread
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import QueuedConnection [as 别名]
def run_on_ui_thread(
bound_slot: MethodType, types: Tuple[type, ...]
) -> Callable[..., None]:
""" Runs an object's slot on the object's own thread.
It's terrible code but it works (as long as the slot has no return value).
"""
qmo = qc.QMetaObject
# QObject *obj,
obj = bound_slot.__self__
# const char *member,
member = bound_slot.__name__
# Qt::ConnectionType type,
# QGenericReturnArgument ret,
# https://riverbankcomputing.com/pipermail/pyqt/2014-December/035223.html
conn = Qt.QueuedConnection
@functools.wraps(bound_slot)
def inner(*args):
if len(types) != len(args):
raise TypeError(f"len(types)={len(types)} != len(args)={len(args)}")
# https://www.qtcentre.org/threads/29156-Calling-a-slot-from-another-thread?p=137140#post137140
# QMetaObject.invokeMethod(skypeThread, "startSkypeCall", Qt.QueuedConnection, QtCore.Q_ARG("QString", "someguy"))
_args = [qc.Q_ARG(typ, typ(arg)) for typ, arg in zip(types, args)]
return qmo.invokeMethod(obj, member, conn, *_args)
return inner
# Begin ConfigModel properties
示例8: __init__
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import QueuedConnection [as 别名]
def __init__(self, argv: list=sys.argv):
super().__init__(argv)
self.handler = CallbackEventHandler()
parser = generate_argument_parser()
self.args = parser.parse_args()
try:
self._create_storage_directories()
self._configure_root_logger()
except Exception as e:
logging.exception("Fatal error starting AutoKey: " + str(e))
self.show_error_dialog("Fatal error starting AutoKey.", str(e))
sys.exit(1)
logging.info("Initialising application")
self.setWindowIcon(QIcon.fromTheme(common.ICON_FILE, ui_common.load_icon(ui_common.AutoKeyIcon.AUTOKEY)))
try:
# Initialise logger
if self._verify_not_running():
self._create_lock_file()
self.monitor = monitor.FileMonitor(self)
self.configManager = cm.get_config_manager(self)
self.service = service.Service(self)
self.serviceDisabled = False
self._try_start_service()
self.notifier = Notifier(self)
self.configWindow = ConfigWindow(self)
self.monitor.start()
# Initialise user code dir
if self.configManager.userCodeDir is not None:
sys.path.append(self.configManager.userCodeDir)
logging.debug("Creating DBus service")
self.dbus_service = AppService(self)
logging.debug("Service created")
self.show_configure_signal.connect(self.show_configure, Qt.QueuedConnection)
if cm.ConfigManager.SETTINGS[cm.IS_FIRST_RUN]:
cm.ConfigManager.SETTINGS[cm.IS_FIRST_RUN] = False
self.args.show_config_window = True
if self.args.show_config_window:
self.show_configure()
self.installEventFilter(KeyboardChangeFilter(self.service.mediator.interface))
except Exception as e:
logging.exception("Fatal error starting AutoKey: " + str(e))
self.show_error_dialog("Fatal error starting AutoKey.", str(e))
sys.exit(1)
else:
sys.exit(self.exec_())