iblqt.core.Worker

class iblqt.core.Worker[source]

Bases: QRunnable

A generic worker class for executing functions concurrently in a separate thread.

This class is designed to run functions concurrently in a separate thread and emit signals to communicate the results or errors back to the main thread.

Adapted from: https://www.pythonguis.com/tutorials/multithreading-pyqt-applications-qthreadpool/

Variables:
  • fn (Callable) – The function to be executed concurrently.

  • args (tuple) – Positional arguments for the function.

  • kwargs (dict) – Keyword arguments for the function.

  • signals (WorkerSignals) – An instance of WorkerSignals used to emit signals.

run() None[source]

The main entry point for running the worker. Executes the provided function and emits signals accordingly.

Return type:

None

__init__(fn, *args, **kwargs)[source]

Initialize the Worker instance.

Parameters:
  • fn (Callable) – The function to be executed concurrently.

  • *args (tuple) – Positional arguments for the function.

  • **kwargs (dict) – Keyword arguments for the function.

run()[source]

Execute the provided function and emit signals accordingly.

This method is the main entry point for running the worker. It executes the provided function and emits signals to communicate the results or errors back to the main thread.

Return type:

None