Python PyQt5.QtCore.QThread() Examples

The following are 30 code examples for showing how to use PyQt5.QtCore.QThread(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module PyQt5.QtCore , or try the search function .

Example 1
Project: socket-test   Author: rookiepeng   File: socket_test.py    License: GNU General Public License v3.0 6 votes vote down vote up
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() 
Example 2
Project: interSubs   Author: oltodosel   File: interSubs.py    License: MIT License 6 votes vote down vote up
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() 
Example 3
Project: kite   Author: pyrocko   File: sandbox_model.py    License: GNU General Public License v3.0 6 votes vote down vote up
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) 
Example 4
Project: kawaii-player   Author: kanishka-linux   File: media_server.py    License: GNU General Public License v3.0 6 votes vote down vote up
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 
Example 5
Project: kawaii-player   Author: kanishka-linux   File: stream.py    License: GNU General Public License v3.0 6 votes vote down vote up
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 
Example 6
Project: kawaii-player   Author: kanishka-linux   File: thread_modules.py    License: GNU General Public License v3.0 6 votes vote down vote up
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 
Example 7
Project: kawaii-player   Author: kanishka-linux   File: thread_modules.py    License: GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, ui_widget, url, img_list=None, get_text=None):
        QtCore.QThread.__init__(self)
        global ui
        self.url = url
        self.interval = 1
        self.picn = 'picn'
        ui = ui_widget
        if img_list:
            """img_list=[img_url, date, ep_url, local_path, site, img_key, dest_dir]"""
            self.img_list = img_list.copy()
        else:
            self.img_list = []
        if get_text:
            self.get_text = True
        else:
            self.get_text = False 
Example 8
Project: DownloaderForReddit   Author: MalloyDelacroix   File: main.py    License: GNU General Public License v3.0 6 votes vote down vote up
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_()) 
Example 9
Project: DownloaderForReddit   Author: MalloyDelacroix   File: DownloadRunner.py    License: GNU General Public License v3.0 6 votes vote down vote up
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() 
Example 10
Project: DownloaderForReddit   Author: MalloyDelacroix   File: DownloadRunner.py    License: GNU General Public License v3.0 6 votes vote down vote up
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() 
Example 11
Project: DownloaderForReddit   Author: MalloyDelacroix   File: DownloaderForRedditGUI.py    License: GNU General Public License v3.0 6 votes vote down vote up
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() 
Example 12
Project: DownloaderForReddit   Author: MalloyDelacroix   File: UserFinderGUI_Obsolete.py    License: GNU General Public License v3.0 6 votes vote down vote up
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() 
Example 13
Project: eddy   Author: danielepantaleone   File: common.py    License: GNU General Public License v3.0 6 votes vote down vote up
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] 
Example 14
Project: pandasgui   Author: adamerose   File: find_toolbar.py    License: MIT License 6 votes vote down vote up
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() 
Example 15
Project: multibootusb   Author: mbusb   File: mbusb_gui.py    License: GNU General Public License v2.0 5 votes vote down vote up
def __init__(self):
        QtCore.QThread.__init__(self) 
Example 16
Project: multibootusb   Author: mbusb   File: mbusb_gui.py    License: GNU General Public License v2.0 5 votes vote down vote up
def __init__(self):
        QtCore.QThread.__init__(self)
        self.thread = GenericThread(uninstall_distro.uninstall_progress) 
Example 17
Project: multibootusb   Author: mbusb   File: mbusb_gui.py    License: GNU General Public License v2.0 5 votes vote down vote up
def __init__(self):
        QtCore.QThread.__init__(self)
        self.error = None
        self.thread = GenericThread(partial(dd_iso_image, self)) 
Example 18
Project: multibootusb   Author: mbusb   File: mbusb_gui.py    License: GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, function, *args, **kwargs):
        QtCore.QThread.__init__(self)
        self.function = function
        self.args = args
        self.kwargs = kwargs 
Example 19
Project: simnibs   Author: simnibs   File: main_gui.py    License: GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, mesh_fn, glHeadModel):
        QtCore.QThread.__init__(self)
        self.fn = mesh_fn
        self.glHeadModel = glHeadModel 
Example 20
Project: simnibs   Author: simnibs   File: main_gui.py    License: GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, session):
        QtCore.QThread.__init__(self)
        self.session = session
        self._stop = False 
Example 21
Project: simnibs   Author: simnibs   File: main_gui.py    License: GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, fn):
        QtCore.QThread.__init__(self)
        self.fn = fn 
Example 22
Project: dcc   Author: amimo   File: fileloading.py    License: Apache License 2.0 5 votes vote down vote up
def __init__(self, parent=None):
        QtCore.QThread.__init__(self, parent)
        self.parent = parent

        self.file_path = None
        self.incoming_file = () 
Example 23
Project: dcc   Author: amimo   File: fileloading.py    License: Apache License 2.0 5 votes vote down vote up
def load(self, file_path):
        self.file_path = file_path
        if file_path.endswith(".ag"):
            self.incoming_file = (file_path, 'SESSION')
        else:
            file_type = androconf.is_android(file_path)
            log.debug("Found filetype: {}".format(file_type))
            self.incoming_file = (file_path, file_type)
        self.start(QtCore.QThread.LowestPriority) 
Example 24
Project: rpi-film-capture   Author: jphfilm   File: fcImgThread.py    License: MIT License 5 votes vote down vote up
def __init__(self, connection, app):
        qtcore.QThread.__init__(self, parent=app)
        self.threadID = 1
        self.name = "ImgThread"
        self.conn = connection 
Example 25
Project: socket-test   Author: rookiepeng   File: socket_test.py    License: GNU General Public License v3.0 5 votes vote down vote up
def on_tcp_client_connect_button_clicked(self):
        if self.ui.button_TcpClient.text() == 'Connect':
            self.ui.button_TcpClient.setEnabled(False)
            self.ui.lineEdit_TcpClientTargetIP.setEnabled(False)
            self.ui.lineEdit_TcpClientTargetPort.setEnabled(False)

            self.tcp_client_thread = QThread()
            self.tcp_client = TCPClient(
                self.ui.label_LocalIP.text(),
                int(self.ui.lineEdit_TcpClientTargetPort.text()))

            self.tcp_client_thread.started.connect(self.tcp_client.start)
            self.tcp_client.status.connect(self.on_tcp_client_status_update)
            self.tcp_client.message.connect(self.on_tcp_client_message_ready)

            self.tcp_client.moveToThread(self.tcp_client_thread)

            self.tcp_client_thread.start()

            self.config['TCP_Client_IP'] = self.ui.label_LocalIP.text()
            self.config['TCP_Client_Port'] = self.ui.lineEdit_TcpClientTargetPort.text()
            self.save_config()

        elif self.ui.button_TcpClient.text() == 'Disconnect':
            self.ui.button_TcpClient.setEnabled(False)
            self.tcp_client.close() 
Example 26
Project: socket-test   Author: rookiepeng   File: socket_test.py    License: GNU General Public License v3.0 5 votes vote down vote up
def on_tcp_server_start_stop_button_clicked(self):
        if self.ui.button_TcpServer.text() == 'Start':
            self.ui.button_TcpServer.setEnabled(False)
            self.ui.lineEdit_TcpServerListenPort.setEnabled(False)
            self.tcp_server_thread = QThread()
            self.tcp_server = TCPServer(
                self.ui.label_LocalIP.text(),
                int(self.ui.lineEdit_TcpServerListenPort.text()))

            self.tcp_server_thread.started.connect(self.tcp_server.start)
            self.tcp_server.status.connect(self.on_tcp_server_status_update)
            self.tcp_server.message.connect(self.on_tcp_server_message_ready)

            self.tcp_server.moveToThread(self.tcp_server_thread)

            self.tcp_server_thread.start()

            self.config['TCP_Server_Port'] = self.ui.lineEdit_TcpServerListenPort.text()
            self.save_config()

        elif self.ui.button_TcpServer.text() == 'Stop':
            self.ui.button_TcpServer.setEnabled(False)
            self.tcp_server.close()

        elif self.ui.button_TcpServer.text() == 'Disconnect':
            self.ui.button_TcpServer.setEnabled(False)
            self.tcp_server.disconnect() 
Example 27
Project: KStock   Author: aseylys   File: Helpers.py    License: GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, int = 5, parent = None):
        QtCore.QThread.__init__(self, parent)
        self.parent = parent
        self.int = int * 1000 
Example 28
Project: PyDev.Debugger   Author: fabioz   File: _debugger_case_qthread4.py    License: Eclipse Public License 1.0 5 votes vote down vote up
def run(self):
        QtCore.QThread.sleep(4)
        print('Done sleeping') 
Example 29
Project: attack_monitor   Author: yarox24   File: exception_worker.py    License: GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, SHOW_MQ, TRAY_MQ, ALARM_MQ, MALWARE_MQ, EXCEPTION_RULES, parent):
        QtCore.QThread.__init__(self, parent)
        self.SHOW_MQ = SHOW_MQ
        self.TRAY_MQ = TRAY_MQ
        self.ALARM_MQ = ALARM_MQ
        self.MALWARE_MQ = MALWARE_MQ
        self.EXCEPTION_RULES = EXCEPTION_RULES
        self.parent = parent
        self.modal_dialog_active = False

        # CONNECT SIGNALS
        self.show_add_exception_dialog.connect(self.parent.show_add_exception_dialog)
        parent.unlock_exception_dialog_signal.connect(self.unlock) 
Example 30
Project: attack_monitor   Author: yarox24   File: tray_worker.py    License: GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, TRAY_MQ, parent):
        QtCore.QThread.__init__(self, parent)
        self.TRAY_MQ = TRAY_MQ
        self.show_alert_signal.connect(parent.show_alert)