Skip to content
Advertisement

How to update PyQt progressbar from an independent function with arguments?

I want to use multiple imported function with arguments that takes some while to run. I want a ‘working’ progress bar that track the processes of that function. I have followed 2 questions already here.

  1. Connect an imported function to Qt5 progress bar without dependencies
  2. Report progress to QProgressBar using variable from an imported module

The difference is that the thread can take any function which can have arguments. The function also not needs to yield the percent to return to the progressbar. The progressbar always start at 0%.

I copied a snippet from first link and modified it for example purpose.

JavaScript

Advertisement

Answer

Do not get too complicated with the answers as they are limited to a very particular context. In general the logic is to pass a QObject to it that updates the percentage value and then emits a signal with that value. For example a simple solution is to use the threading module:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement