Mar-10-2019, 01:50 PM
(Mar-04-2019, 11:28 AM)Alfalfa Wrote:(Mar-04-2019, 05:50 AM)mrdominikku Wrote: @Alfalfa, thanks for response, 1st and 3rd applied, but still can't make 2nd work. It doesn't crash program or anything, but either emit signal or call class procedure don't update progress bar :( I added part of convert module below.
Your usage of threading, slot and signals is incorrect. Look again at the example I gave you above. If you have trouble understanding how it work, I propose you start with this very short threading example and grow your program around it.
Been searching for few solutions and still don't get it. In PyQt5 documentation is described how to use signals and slot, but even after using them I can't call emit signal from another module, but I can emit from same module.
#*******ui_main.py module******* class Window(QtBaseClass, Ui_MainWindow): def __init__(self, parent=None): super(QtBaseClass, self).__init__(parent) self.setupUi(self) self.worker = ThreadClass(self) #<-- thread class initialize self.worker.signal.connect(self.update_progress_bar) # <--connecting slot to signal def update_progress_bar(self, progress_val): self.input_progress_bar.setValue(progress_val) def process_input(self): self.worker.start() #<-- starting thread class ThreadClass(QThread): signal = QtCore.pyqtSignal(int) #<-- my signal def __init__(self, window, parent=None): super(ThreadClass, self).__init__(parent) self.window = window def run(self): self.signal.emit(20) #<--that's work convert.convert_main(self.signal, self.window.input_line.text()) #<--pass signal to another module #**********convert.py module**** def convert_main(s_thread, input_array): s_thread.emit(20) #<-- that's not working