Implementing a background process in PyQt5 using QThread

Поделиться
HTML-код
  • Опубликовано: 8 сен 2024

Комментарии • 71

  • @saadmansuri4092
    @saadmansuri4092 3 года назад +37

    I spend a WHOLE month trying to understand pyqt thread signals, looking at hundreds of StackOverflow questions and articles but this video specifically is so well executed that I regret not clicking on your video at first. Straight to the point, easy example, live execution, and explanation at the same time. Mr.Miller, you sir, just saved my academic project.

    • @Bloody_River
      @Bloody_River 3 года назад +2

      The same! I spend whole 1 day to make a progress bar with thread... omg.

  • @Skryzeeful
    @Skryzeeful 3 года назад +3

    Thank you, I was in charge of building the entire GUI for my engineering group's capstone and I had no prior experience with multi-threading. The GUI remained unresponsive and I figured it would need threading but I just couldn't figure out how I can integrate my group's back end system. It involved several data streams each being run in separate loops but by allocating threads for each data stream, The GUI became responsive allowing me to execute changes in the GUI while it was waiting for data . This video greatly helped me understand how to use workers to do all the data processing and then communicate to the GUI. Excellent Vid!

  • @skaleee1207
    @skaleee1207 2 месяца назад

    This video cleared some uncertainties that I had. Thanks!

  • @drippyash7376
    @drippyash7376 Год назад +1

    You are the best. I didn’t found anyone that explains this. And you explain it sooooo simple. Keep on doing tutorials, I need you.

  • @arielspalter7425
    @arielspalter7425 Год назад

    Friend, I’ve been banging my head against the walls for a week now, trying to figure this out. Thanks to you I FINALLY get it. Thank you!

  • @highfacility9200
    @highfacility9200 2 года назад +1

    Best threading video i have ever seen in my life. Thanks a lot Mike!

  • @todbajovski7540
    @todbajovski7540 2 года назад +2

    Thank you so much. This is exactly what i needed and what no one on the internet couldn't explain as good as you did.

  • @dyer308
    @dyer308 3 года назад +2

    Damm you just explained qthreads, signals, slots perfectly in 15 minutes, much thanks sir 🙏

  • @sandokan888
    @sandokan888 2 года назад +2

    Thank you so much man. You explained it so well and the example was easy to understand. I struggled for days to get it how python threads work but I finally got it.

  • @CreativeGeekCG
    @CreativeGeekCG 3 года назад

    I stayed up for the last 26 hours trying to understand multithreading until I came to this video!
    Really, thank you.
    for anyone reading this, check out his course on udemy (linked in the description).

  • @neighbor-outlet
    @neighbor-outlet Год назад

    hi! mike. i saw this video after finding alot of document about Thread. but i have never seen the better document before. thanks alot. And i hope u make more useful video.

  • @user-bs4pu1ms8b
    @user-bs4pu1ms8b Год назад

    The best explanation in RUclips. Even for me as a forener.

  • @rodrigokea
    @rodrigokea 2 года назад

    Thanks man, looking for this for a while.

  • @thewadegreen
    @thewadegreen 3 года назад +4

    Thank you for this video, I've been trying to figure this out for a long time, this was a great explanation!

  • @CraigHollabaugh
    @CraigHollabaugh 3 года назад +1

    I'm agreeing with others, this is an exceptionally informative video that quickly explains QThread fundamentals.

  • @aliaria786
    @aliaria786 2 года назад

    I don’t comment at all, but this made me. To the point video, simply explained.

  • @TheBlackSheep291
    @TheBlackSheep291 2 года назад

    Saved my Master Thesis Prototyp, well explained and an easy example, thx!!!

  • @mauronunes7196
    @mauronunes7196 10 месяцев назад

    Very clear explanation, this saved my ass, many thanks

  • @xsandwichxxsandwichx1778
    @xsandwichxxsandwichx1778 3 года назад +1

    Thank you Mike for this nice explanation, through your video i understood this very quickly.

  • @ddssus1
    @ddssus1 Год назад

    Thanks a lot, man. This is exactly what explain to me. Easy sample, easy understood.

  • @faizanamir5251
    @faizanamir5251 3 года назад +1

    very simple examples man. Really wish had seen it earlier. Thanks!

  • @bukugratis5529
    @bukugratis5529 2 года назад

    Very clear and simple explanation , thank you Mike

  • @user-kv3je7fk6v
    @user-kv3je7fk6v 3 года назад

    The best explanation on this topic

  • @masmadp9612
    @masmadp9612 Год назад

    Great video! Thanks a lot for your clear explanation and understanding!

  • @sernight2457
    @sernight2457 3 года назад

    Great! Everything is simply explained. Thank you so much! You helped me a lot!

    • @sernight2457
      @sernight2457 3 года назад +1

      But I have a question. Can i emit a signal the same way but in another direction?

  • @bartosztajak9964
    @bartosztajak9964 2 года назад

    very good explanation in an easy way.

  • @simonohler9385
    @simonohler9385 2 года назад

    So well explained! Thanks for this!

  • @khanafeer
    @khanafeer 2 года назад

    thanks man for the good explanation

  • @michaelmanuel1676
    @michaelmanuel1676 3 года назад

    Thank you you are the best!!!

  • @erikmeiler9736
    @erikmeiler9736 2 года назад

    Best video on QThread, no questions asked. One thing that is a little unclear to me is when you are catching the signal in the custom slot, I am not sure where the variable "val" comes in to place in the line of code "def evt_update_progress(self, val):"... How is "val" capturing the signal emitted from the worker thread?

  • @praveenkumawat2662
    @praveenkumawat2662 3 года назад

    Thank you so much Mike for sharing this. I am going to subscribe and share the video

  • @whatisahandleeee
    @whatisahandleeee 2 года назад

    You're my hero ❤

  • @MrJonathanRB
    @MrJonathanRB 3 года назад

    Mr Miller Sir, Thanks a lot!!!!!

  • @ferdaws45
    @ferdaws45 Год назад

    Thank You !, for sharing.

  • @mail4mikew
    @mail4mikew 3 года назад

    Nice video, well explained, I learned a lot. Thanks!

  • @jineshr6116
    @jineshr6116 2 года назад

    Man you are awsome!! Thanks a lot

  • @laika9138
    @laika9138 Год назад

    Thanks for the video.
    You are sending a signal with a value generated inside the worker class, but how about sending a signal from a main method to the worker thread function?

  • @RemshidAbdulSathar
    @RemshidAbdulSathar 3 года назад +1

    Thanks for the video!

  • @yarmik3d
    @yarmik3d 2 года назад +1

    Unfortunately, the author does not respond to questions in the comments, but still say. I can't imagine any application where data comes from a separate thread to the main thread and doesn't come from the main thread to a separate one, what can you process in a separate thread without getting anything from the main thread?

  • @juliocoelho4706
    @juliocoelho4706 3 года назад

    Thank you! It is going to be very helpful!

  • @mujibbasha871
    @mujibbasha871 4 года назад +1

    thanks for this , It's help me alot , thanks

  • @mashoodurrehman9840
    @mashoodurrehman9840 3 года назад

    thanks man for saving my project :)

  • @shinkevin3379
    @shinkevin3379 Год назад

    Thank you so much for your tutorial. Can you integrate this idea with Qtimer() rather than using a fixed size of for-loop?

  • @mohamedakhiat1014
    @mohamedakhiat1014 Год назад

    So how do you solve it if the loop we are running on another thread - so the GUI doesn't freeze - uses variables from the DlgMain() and is 100% dependent on the DlgMain()

  • @santiagomendezmejia7155
    @santiagomendezmejia7155 2 года назад

    Thanks a lot man!

  • @rouuux
    @rouuux 3 года назад

    You're a god

  • @slambergamer91
    @slambergamer91 2 года назад

    Hi thank you for the tutorial.. its great and easy to understand.. however i got 1 question how do we tackle issue that i need (example) to data from self.textEdit_2.toPlainText() in program that is in classWorkerThread and how do i trasmit multiple signal to the main GUI thank you!

  • @zefault
    @zefault 3 года назад

    love this video, thank you!

  • @user-eu4wn9pu2g
    @user-eu4wn9pu2g 2 года назад

    thank you!!

  • @Hubieee
    @Hubieee 2 года назад

    What I dont get is: If I have a custom function that does a special job and I want it to run in a thread... do I need to define a unique class for every function or can I somehow pass the function to a general QThread class? ... This seems too messy :X
    Especially when I have a controller class that gets the UI and a model from two other classes and acts as the mediator. Now I must take a function from my model and create a QThread Subclass where I exchange the run() function with the functionality of my model function? :X

  • @ABHISHEKMAURYA-vx5si
    @ABHISHEKMAURYA-vx5si 3 года назад

    This is exactly what I was looking for, Thanks 😊

  • @dattatrayachitale2988
    @dattatrayachitale2988 3 года назад

    hello, thanks for video but in my case i need to access few variable from QT class in thread class and which look impossible to access one veribale of one class into another, so what can do foe it?

  • @MrFaustotromba
    @MrFaustotromba Год назад

    thank ypu !

  • @mahdiyaghoubi4033
    @mahdiyaghoubi4033 3 года назад

    can someone help me?
    i have created a Countdown GUI app and i wanna use Threads but don't know how to! because as you know a countdown app have hours, minutes and seconds. i have create a button Start to start counting down from the inputs of user for hours,minutes and seconds! how can i update these 3 ? without any freezing

  • @ApoloEmanuel
    @ApoloEmanuel 2 года назад

    Thanks bro

  • @muhammettarkerkanyldz5982
    @muhammettarkerkanyldz5982 2 года назад

    Can we define multiple worker class

  • @thomasheinzm.9094
    @thomasheinzm.9094 3 года назад

    Sir how do you then the message from the background to the Gui ?

  • @bennguyen1313
    @bennguyen1313 3 года назад

    Is there any performance difference between using python's multiprocessing (mp) vs pyqt's QThreads vs regular threading? For example, according to "Multithreading PyQt applications with QThreadPool" "Use PyQt's QThread to Prevent Freezing GUIs":
    class Signals(QObject):
    return_signal = pyqtSignal(str)
    class Thread(QRunnable):
    signal = pyqtSignal(str)
    def __init__(self):
    super(Thread, self).__init__()
    self.signal = Signals()
    @pyqtSlot()
    def run(self):
    result = "Some String"
    self.signal.return_signal.emit(result)
    class App(QWidget):
    def __init__(self):
    super().__init__()
    self.title='Hello, world!'
    self.threadpool = QThreadPool()
    self.initUI()
    def initUI(self):
    self.setWindowTitle(self.title)
    self.setGeometry(self.left,self.top,self.width,self.height)
    checkbox = QCheckBox('Check Box', self)
    checkbox.stateChanged.connect(self.clickCheckbox)
    self.show()
    def clickCheckbox(self):
    thread = Thread()
    thread.signal.return_signal.connect(self.function_thread)
    self.threadpool.start(thread)
    def function_thread(self, signal):
    print(signal)
    if __name__=='__main__':
    app=QApplication(sys.argv)
    ex=App()
    sys.exit(app.exec_())

  • @thelostman5625
    @thelostman5625 3 года назад

    So, when we wanna pass parameters to the run function while starting the working thread, how would we do that?
    as in below example
    class WorkingThread(QThread):
    def run(self, passed_params):
    do_something_according_to_passed params
    and can we define our own function apart from run?

    • @laika9138
      @laika9138 Год назад

      did you find something?

    • @thelostman5625
      @thelostman5625 Год назад

      @@laika9138 yes but I forgot how I solved it. 😁

  • @easy_tech4169
    @easy_tech4169 3 года назад

    best man i have a problème Wen i Install my application antivirus Is detected like a virus and deleted

  • @altank8062
    @altank8062 3 года назад

    def speak(audio):
    Work=Worker()
    Work.start()
    class Worker(QThread):
    def run(self):
    engine.say(audio)
    engine.runAndWait()
    how do i pass the audio var to def run ?

    • @GordonAitchJay
      @GordonAitchJay 3 года назад +1

      You could create an __init__ method for your Worker class that takes another argument which then assigns it to self.audio. Then in your run method you could access it with self.audio.

  • @runawayforeskin431
    @runawayforeskin431 3 года назад

    thx man

  • @ytpedia_
    @ytpedia_ 2 года назад

    next qthreadpool please

  • @Life-zx5wp
    @Life-zx5wp 3 года назад

    please make your text bigger