开发者

How to initialize a QT thread in python

开发者 https://www.devze.com 2022-12-18 19:29 出处:网络
As per examples seen online, I\'ve created a Worker thread.I\'m looking for a thread to run my GUI while one thread executes my code.Worker thread is defined as:

As per examples seen online, I've created a Worker thread. I'm looking for a thread to run my GUI while one thread executes my code. Worker thread is defined as:

class Worker(QThread):

    def __init__(self, parent = None):
        QThread.__init__(self, parent)
        self.exiting = False
        self.size = QSize(0开发者_开发问答, 0)

    def __del__(self):
        self.exiting = True
        self.wait()

pretty simple. Within my Window class, I have this line in the __init__ function: self.thread = Worker(). However, I never do anything with that self.thread afterwards. What am I supposed to be doing with it? This does not seem to be laid out as nicely as other threading mechanisms..


I imagine you're looking at the example here? But that example does "do something with that thread afterwards" -- it hooks up methods to respond to the signals the thread sends when it starts and finishes, in the class Worker it defines a run method that draws random stars , etc etc. Not sure what you think is wrong with how this is "laid out"?

0

精彩评论

暂无评论...
验证码 换一张
取 消