本文整理汇总了Python中PyQt5.QtCore.QThread方法的典型用法代码示例。如果您正苦于以下问题:Python QtCore.QThread方法的具体用法?Python QtCore.QThread怎么用?Python QtCore.QThread使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore
的用法示例。
在下文中一共展示了QtCore.QThread方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_udp_server_start_stop_button_clicked
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QThread [as 别名]
def on_udp_server_start_stop_button_clicked(self):
if self.ui.button_Udp.text() == 'Start':
self.ui.button_Udp.setEnabled(False)
self.ui.lineEdit_UdpListenPort.setEnabled(False)
self.udp_thread = QThread()
self.udp_server = UDPServer(
self.ui.label_LocalIP.text(),
int(self.ui.lineEdit_UdpListenPort.text()))
self.udp_thread.started.connect(self.udp_server.start)
self.udp_server.status.connect(self.on_udp_server_status_update)
self.udp_server.message.connect(self.on_udp_server_message_ready)
self.udp_server.moveToThread(self.udp_thread)
self.udp_thread.start()
self.config['UDP_Listen_Port'] = self.ui.lineEdit_UdpListenPort.text()
self.save_config()
elif self.ui.button_Udp.text() == 'Stop':
self.ui.button_Udp.setEnabled(False)
self.udp_server.close()
示例2: __init__
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QThread [as 别名]
def __init__(self):
super().__init__()
self.thread_subs = QThread()
self.obj = thread_subtitles()
self.obj.update_subtitles.connect(self.render_subtitles)
self.obj.moveToThread(self.thread_subs)
self.thread_subs.started.connect(self.obj.main)
self.thread_subs.start()
self.thread_translations = QThread()
self.obj2 = thread_translations()
self.obj2.get_translations.connect(self.render_popup)
self.obj2.moveToThread(self.thread_translations)
self.thread_translations.started.connect(self.obj2.main)
self.thread_translations.start()
# start the forms
self.subtitles_base()
self.subtitles_base2()
self.popup_base()
示例3: __init__
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QThread [as 别名]
def __init__(self, sandbox_model=None, *args, **kwargs):
QtCore.QObject.__init__(self)
self.model = sandbox_model
self.log = SceneLogModel(self)
self.sources = SourceModel(self)
self.cursor_tracker = CursorTracker(self)
self._log_handler = logging.Handler()
self._log_handler.setLevel(logging.DEBUG)
self._log_handler.emit = self.sigLogRecord.emit
logging.root.setLevel(logging.DEBUG)
logging.root.addHandler(self._log_handler)
self.worker_thread = QtCore.QThread()
self.moveToThread(self.worker_thread)
self.worker_thread.start()
if self.model:
self.setModel(self.model)
示例4: __init__
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QThread [as 别名]
def __init__(self, ip, port, ui_widget=None, hm=None, logr=None, window=None):
global ui, MainWindow, home, logger, html_default_arr, getdb
global BASEDIR, TMPDIR, OSNAME
QtCore.QThread.__init__(self)
self.ip = ip
self.port = int(port)
self.cert_signal.connect(generate_ssl_cert)
self.media_server_start.connect(media_server_started)
self.httpd = None
logger = logr
ui = ui_widget
home = hm
MainWindow = window
arg_dict = ui.get_parameters_value(
r='html_default_arr', b='BASEDIR', t='TMPDIR')
#logger.info(arg_dict)
html_default_arr = arg_dict['html_default_arr']
BASEDIR = arg_dict['BASEDIR']
TMPDIR = arg_dict['TMPDIR']
OSNAME = os.name
if ui.getdb is None:
getdb = ServerLib(ui, home, BASEDIR, TMPDIR, logger)
elif isinstance(ui.getdb, ServerLib):
logger.info('--server--initiated---2477--')
getdb = ui.getdb
示例5: __init__
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QThread [as 别名]
def __init__(self, v1, v2, v3, v4, row=None, from_client=None):
QtCore.QThread.__init__(self)
self.handle = v1
self.count = v2
self.count_limit = v3
self.session = v4
if row:
self.current_index = row
else:
self.current_index = 0
self.from_client = from_client
self.start_next = False
self.session_signal.connect(session_finished)
self.progress_signal.connect(print_progress)
self.progress_signal_end.connect(print_progress_complete)
self.ui = None
示例6: __init__
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QThread [as 别名]
def __init__(
self, ui_widget, logr, tmp, name, url=None, direct_url=None,
copy_fanart=None, copy_poster=None, copy_summary=None,
use_search=None, video_dir=None):
QtCore.QThread.__init__(self)
global ui, logger, TMPDIR, site, siteName
ui = ui_widget
logger = logr
TMPDIR = tmp
self.name = name
self.url = url
self.direct_url = direct_url
self.copy_fanart = copy_fanart
self.copy_poster = copy_poster
self.copy_summary = copy_summary
self.use_search = use_search
self.video_dir = video_dir
self.image_dict_list = {}
self.dest_dir = ''
self.summary_signal.connect(copy_information)
self.thumb_signal.connect(update_playlist_widget)
self.imagesignal.connect(update_image_list)
site = ui.get_parameters_value(s='site')['site']
siteName = ui.get_parameters_value(s='siteName')['siteName']
self.site = site
示例7: main
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QThread [as 别名]
def main():
Logger.make_logger()
sys.excepthook = log_unhandled_exception
app = QtWidgets.QApplication(sys.argv)
queue = Injector.get_queue()
thread = QtCore.QThread()
receiver = MessageReceiver(queue)
window = DownloaderForRedditGUI(queue, receiver)
receiver.output_signal.connect(window.update_output)
receiver.moveToThread(thread)
thread.started.connect(receiver.run)
receiver.finished.connect(thread.quit)
receiver.finished.connect(receiver.deleteLater)
thread.finished.connect(thread.deleteLater)
thread.start()
window.show()
sys.exit(app.exec_())
示例8: start_extractor
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QThread [as 别名]
def start_extractor(self):
"""
Initializes an Extractor object, starts a separate thread, and then runs the extractor from the new thread so
that content can be simultaneously extracted, validated, and downloaded.
"""
self.extraction_runner = ExtractionRunner(self.queue, self.validated_objects, self.queued_posts, self.user_run)
self.stop.connect(self.extraction_runner.stop)
self.extraction_thread = QThread()
self.extraction_runner.moveToThread(self.extraction_thread)
self.extraction_thread.started.connect(self.extraction_runner.run_extraction)
self.extraction_runner.update_progress_bar.connect(self.update_progress_bar)
self.extraction_runner.send_failed_extract.connect(self.send_failed_extract)
self.extraction_runner.finished.connect(self.extraction_thread.quit)
self.extraction_runner.finished.connect(self.extraction_runner.deleteLater)
self.extraction_thread.finished.connect(self.extraction_thread.deleteLater)
self.extraction_thread.start()
示例9: start_downloader
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QThread [as 别名]
def start_downloader(self):
"""
Initializes a Downloader object, starts a separate thread, and then runds the downloader from the new thread so
that content can be simultaneously downloaded, extracted and validated.
:return:
"""
self.downloader = Downloader(self.queued_posts, self.settings_manager.max_download_thread_count)
self.stop.connect(self.downloader.stop)
self.downloader_thread = QThread()
self.downloader.moveToThread(self.downloader_thread)
self.downloader_thread.started.connect(self.downloader.download)
self.downloader.download_count_signal.connect(self.set_final_download_count)
self.downloader.send_downloaded.connect(self.add_downloaded_object)
self.downloader.finished.connect(self.downloader_thread.quit)
self.downloader.finished.connect(self.downloader.deleteLater)
self.downloader_thread.finished.connect(self.downloader_thread.deleteLater)
self.downloader_thread.finished.connect(self.downloads_finished)
self.downloader_thread.start()
示例10: check_for_updates
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QThread [as 别名]
def check_for_updates(self, from_menu):
"""
Opens and runs the update checker on a separate thread. Sets self.from_menu so that other dialogs know the
updater has been ran by the user, this will result in different dialog behaviour
"""
self.update_thread = QtCore.QThread()
self.update_checker = UpdateChecker(self.version)
self.update_checker.moveToThread(self.update_thread)
self.update_thread.started.connect(self.update_checker.run)
if from_menu:
self.update_checker.update_available_signal.connect(self.update_dialog)
self.update_checker.no_update_signal.connect(self.no_update_available_dialog)
else:
self.update_checker.update_available_signal.connect(self.display_update)
self.update_checker.finished.connect(self.update_thread.quit)
self.update_checker.finished.connect(self.update_checker.deleteLater)
self.update_thread.finished.connect(self.update_thread.deleteLater)
self.update_thread.start()
示例11: download_user_samples
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QThread [as 别名]
def download_user_samples(self):
"""
Creates an instance of the DownloadRunner class and moves it to another thread where it then downloads the
specified number of posts from the found users
"""
if len(self.found_users) > 0 and self.watchlist_download_sample_spinbox_2.value() > 0:
self.found_user_output.append('Starting Download\n')
self.reddit_extractor = DownloadRunner(self.found_users, None, self.queue,
self.watchlist_download_sample_spinbox_2.value(), self.save_path,
None, None, False, False, None, None, None)
self.user_finder_download_thread = QtCore.QThread()
self.reddit_extractor.moveToThread(self.user_finder_download_thread)
self.user_finder_download_thread.started.connect(self.reddit_extractor.validate_users)
self.reddit_extractor.finished.connect(self.user_finder_download_thread.quit)
self.reddit_extractor.finished.connect(self.reddit_extractor.deleteLater)
self.user_finder_download_thread.finished.connect(self.user_finder_download_thread.deleteLater)
self.user_finder_download_thread.finished.connect(self.download_finished)
self.user_finder_download_thread.start()
elif len(self.found_users) > 0 >= self.watchlist_download_sample_spinbox_2.value():
pass
else:
self.found_user_output.append('No users found that meet criteria\n')
self.download_finished()
示例12: stopThread
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QThread [as 别名]
def stopThread(self, name_or_qthread):
"""
Stop a running thread.
:type name_or_qthread: T <= str | QThread
"""
if name_or_qthread:
name = name_or_qthread
if not isinstance(name, str):
name = name_or_qthread.objectName()
if name in self._threads:
try:
#LOGGER.debug("Terminate thread: %s (runtime=%.2fms)", name, time.monotonic() - self._started[name])
qthread = self._threads[name]
qthread.quit()
if not qthread.wait(2000):
qthread.terminate()
qthread.wait()
except Exception as e:
LOGGER.exception('Thread shutdown could not be completed: %s', e)
del self._threads[name]
if name in self._workers:
del self._workers[name]
if name in self._started:
del self._started[name]
示例13: __init__
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QThread [as 别名]
def __init__(self, df, text, match_flags, parent=None):
'''
Thread to search DataFrame for a string.
Args:
df: Type pd.DataFrame
text: Text to search for. Type string.
match_flags: User enabled match flags. Can match case, regex, or exact.
Type dict.
'''
QtCore.QThread.__init__(self, parent=parent)
self.isRunning = True
self.df = df
self.text = text
self.match_flags = match_flags
self.max_chunk_size = 10000
self.chunks = self.split_chunks()
示例14: __init__
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QThread [as 别名]
def __init__(self):
QtCore.QThread.__init__(self)
示例15: __init__
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QThread [as 别名]
def __init__(self, mesh_fn, glHeadModel):
QtCore.QThread.__init__(self)
self.fn = mesh_fn
self.glHeadModel = glHeadModel