Answer the question
In order to leave comments, you need to log in
How to create an extra thread in PyQt5?
I have 2 scripts:
ui.py - which contains the ui of my program (compiled with ui.ui )
and the main script - program.py - which contains the program logic, there is the main code and the ui change.
There is a function in the program.py script - send_message() which sent a message to the mail using smtp
I call send_message when the button is clicked:
ui.start_button.clicked.connect(send_message)
And everything worked fine, the messages were sent but the ui (interface) was hanging. I googled and realized that I need to do it all from more than one thread, so I created a function that worked when the button was pressed.
import threading
def new_thread():
thread = threading(target=send_message)
thread.start()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question