anonymous | 2020-05-11 07:08:24 UTC | #1
1st: This is a great tutorial! Probably one of the best ones I have ever seen. 2nd: I tried to create a little GUI with your code, but I ran into a problem I cannot solve. I added a class for giving back the status to the GUI,
self.STATI = [Status(ID=i, callback=self.postStatus) for i in range(SLOTS)]
...
class Main():
def Button_clkd(self):
self.workFunc(process, "parameter")
def workFunc(self, *argv):
self.ui.resultWindow(self)
self.timer.setInterval(2000)
for job in self.jobs:
self.total_jobs += 1
self.STATI[job].reset()
worker = Worker(argv[0], self.jobs[job], val, self.STATI[job])
worker.signals.result.connect(self.postResult)
self.threadpool.start(worker)
def postStatus(self, STATUS):
#print("STATUS:", STATUS.id)
lables_list = self.ui.resultBox.findChildren(QtWidgets.QLabel)
lables_list[STATUS.id].setText("Slot "+ str(STATUS.id) +" job: "+ STATUS.status)
if STATUS.status == True:
self.timer.setInterval(500)
class Status():
def **init** (self, ID, callback=lambda callbackparameter: None):
self.status = ""
self.callback = callback
self.id = ID
def update(self, callbackparameter):
self.status = callbackparameter
self.callback(self)
def reset(self):
self.status = ""
In another file I have a function that simply prints or puts a value to STATUS.status
and this sometimes just does nothing - I seem not to be able to figure out why. Can you maybe point me in the right direction?
Is it possible that my QDialog
blocks all my input? Is this because it is executed by exec_()?
I already have samples of code where I can dynamically update the labels in the QDialog
class, but I cannot figure out what makes it "stop" - meaning, that after I closed the QDialog
window, all my prints are shown in the console - but nothing before (not even errors).
PyQt6 Crash Course — a new tutorial in your Inbox every day
Beginner-focused crash course explaining the basics with hands-on examples.