Qthread 问题

楼主: noshare (zzz...)   2017-12-06 20:39:14
因为想学习使用Qthread方式来避免pyqt的画面会冻结的问题。
以下是我的程式码
class MyWidget(QWidget):
def __init__(self, parent = None):
super(MyWidget, self).__init__(parent)
...
def createLayout(self):
self.button_config= QPushButton(self)
combo_box_option = ["1","3","5","10","20"]
self.combo = QComboBox(self)
for t in combo_box_option:
self.combo.addItem(t)
...
...
thread = MyThread()
thread.changed_signal.connect(self.update)
self.button_config.clicked.connect(lambda :thread.start())
def update(self):
config_result = int(self.combo_box_option.currentText())
class MyThread(QThread):
changed_signal = pyqtSignal(int)
def __init__(self,parent=None):
super(MyThread,self).__init__(parent)
def run(self):
for i in range(x):
self.sec_changed_signal.emit(i)
time.sleep(1)
想知道有没有办法让最后一个for循环里面的x值,
能够等于前一个class里面最后一行下拉式选择后的config_result
或是有其他种写法可以达成在使用循环时,GUI不会出现无法反应的状态。
谢谢各位~

Links booklink

Contact Us: admin [ a t ] ucptt.com