Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

How to get a self.count from a MainWindow class to Class Mythread run() count

class MainWindow(QtWidgets.QMainWindow): 
    def buttonClicked(self):
        self.my_thread.start()
         count = self.ui.lineEdit.text()
         self.ui.lineEdit.setText(count)
         self.count = int(self.ui.lineEdit.text())      

class MyThread(QThread):                
    def run(self):   
        for i in range(1,int(count)):
        self.my_signal_1.emit(str(i))
        board.digital[8].write(1)
        board.digital[13].write(1)
        time.sleep(float(down_duration))
        board.digital[8].write(0)
        board.digital[13].write(0)
        time.sleep(float(up_duration))                     
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
159 views
Welcome To Ask or Share your Answers For Others

1 Answer

You could create getter/setters to access the variable, and then access it with those methods from the run method.

PS: Your for loop is not indented correctly. All for loops need to be indented for Python to recognize them.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...