本文整理汇总了Python中AnyQt.QtCore.QThread.quit方法的典型用法代码示例。如果您正苦于以下问题:Python QThread.quit方法的具体用法?Python QThread.quit怎么用?Python QThread.quit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtCore.QThread
的用法示例。
在下文中一共展示了QThread.quit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_task
# 需要导入模块: from AnyQt.QtCore import QThread [as 别名]
# 或者: from AnyQt.QtCore.QThread import quit [as 别名]
def test_task(self):
results = []
task = Task(function=QThread.currentThread)
task.resultReady.connect(results.append)
task.start()
self.app.processEvents()
self.assertSequenceEqual(results, [QThread.currentThread()])
thread = QThread()
thread.start()
try:
task = Task(function=QThread.currentThread)
task.moveToThread(thread)
self.assertIsNot(task.thread(), QThread.currentThread())
self.assertIs(task.thread(), thread)
results = Future()
def record(value):
# record the result value and the calling thread
results.set_result((QThread.currentThread(), value))
task.resultReady.connect(record, Qt.DirectConnection)
task.start()
f = task.future()
emit_thread, thread_ = results.result(3)
self.assertIs(f.result(3), thread)
self.assertIs(emit_thread, thread)
self.assertIs(thread_, thread)
finally:
thread.quit()
thread.wait()
示例2: VizRankDialog
# 需要导入模块: from AnyQt.QtCore import QThread [as 别名]
# 或者: from AnyQt.QtCore.QThread import quit [as 别名]
#.........这里部分代码省略.........
set_attr_callback: the callback for setting the projection chosen
in the vizrank
Returns:
tuple with Vizrank dialog instance and push button
"""
# Monkey patching could be avoided by mixing-in the class (not
# necessarily a good idea since we can make a mess of multiple
# defined/derived closeEvent and hideEvent methods). Furthermore,
# per-class patching would be better than per-instance, but we don't
# want to mess with meta-classes either.
vizrank = cls(master)
button = gui.button(
widget, master, button_label, callback=vizrank.reshow,
enabled=False)
vizrank.selectionChanged.connect(lambda args: set_attr_callback(*args))
master_close_event = master.closeEvent
master_hide_event = master.hideEvent
master_delete_event = master.onDeleteWidget
def closeEvent(event):
vizrank.close()
master_close_event(event)
def hideEvent(event):
vizrank.hide()
master_hide_event(event)
def deleteEvent():
vizrank.keep_running = False
if vizrank._thread is not None and vizrank._thread.isRunning():
vizrank._thread.quit()
vizrank._thread.wait()
master_delete_event()
master.closeEvent = closeEvent
master.hideEvent = hideEvent
master.onDeleteWidget = deleteEvent
return vizrank, button
def reshow(self):
"""Put the widget on top of all windows
"""
self.show()
self.raise_()
self.activateWindow()
def initialize(self):
"""
Clear and initialize the dialog.
This method must be called by the widget when the data is reset,
e.g. from `set_data` handler.
"""
if self._thread is not None and self._thread.isRunning():
self.keep_running = False
self._thread.quit()
self._thread.wait()
self.keep_running = False
self.scheduled_call = None
self.saved_state = None
self.saved_progress = 0
self.update_timer.stop()