[PyQt] Basic thread question
Phil
phil_lor at bigpond.com
Fri Sep 29 10:03:17 BST 2017
Thank you for reading this.
Using Eric, I have created a simple GUI. This is part of the GUI class
that includes a dial.
What I'd like to do is sweep the dial back and forth and to do this I
can see that I need a thread so that I don't block the GUI. My question
is, where do I place the thread class? If I place it in the same file
after the MainWindow class, how do I then access the dial? I don't think
the thread class is added to main_script.py. At the moment, I cannot see
how to access the dial from there anyway.
This the Eric generated class:
class MainWindow(QMainWindow, Ui_MainWindow):
"""
Class documentation goes here.
"""
def __init__(self, parent=None):
"""
etc.
I know that this is not totally correct, but just say that I wanted to
step the dial point along at a one second rate. How should I proceed?
import threading
import time
class MyThread(threading.Thread):
def __init__(self, your_string):
threading.Thread.__init__(self)
def run(self):
for i in range(100):
self.dial.setValue(i)
time.sleep(1)
--
Regards,
Phil
More information about the PyQt
mailing list