Bhuvan | 2020-05-10 21:25:01 UTC | #1
How to pass the additional
execute_this_fn below is my code
worker = Worker(lambda :self.execute_this_fn(arg1, arg2, kwarg1)
I am getting
TypeError: <lambda>() got an unexpected keyword argument 'progress_callback'
pvn | 2020-05-10 21:09:54 UTC | #2
Have u got a chance to figured this out? I have the same problem.
Because I have an error when I'm passing parameters to function like this:
worker = Worker(self.execute_this_fn, param1, param2)
TypeError: execute_this_fn() got multiple values for argument 'progress_callback'
anonymous | 2020-05-10 21:13:13 UTC | #3
Hi, i have experimented quite a lot with the classes and QThreadPool concepts in this tutorial. By far the best i could find on the topic!.
In your slot function, you must add a
**kwargs whether you plan to emit the signal or not, because the
progress_callback is added as a keyword argument automatically in the Worker
Check it out:
class Worker(QRunnable): ... def **init** (self, self.kwargs['progress_callback'] = self.signals.progress
Colin_Wu | 2020-05-11 11:45:51 UTC | #4
Sorry coming late to this party but here's what I found works (so far):
def exec_this_fn(self, progress_callback, start=0): for n in range(start, 5):
Then in the
oh_no function, change worker initiation to
worker = Worker(self.execute_this_fn, start=2)
In this trivial example, the "start" parameter lets me start the count from 2 rather than 0.
Hope this helps.
Bhuvan | 2020-05-11 11:56:38 UTC | #5
Thank you for your reply, Your answer was much helpful, I am facing new problem please can you help me? I have pyqtgraph window inside my QDialog, i am calling the QDialog from my mainwindow application (through Worker thread), some times the QDialog runs proprely, some times the whole GUI is crashes with out giving any error message. If i wont run the QDialog from Worker thread the QDialog will freeze until the task in completed.
My final intention is to run the sub window (QDialog) in thread, with out being freeze.
[[ discount.discount_pc ]]% OFF for [[discount.description ]] with the code [[ discount.coupon_code ]]