diff options
| author | Robert Honz <exislow+github@gmail.com> | 2023-12-19 23:58:57 +0100 |
|---|---|---|
| committer | Robert Honz <exislow+github@gmail.com> | 2023-12-19 23:58:57 +0100 |
| commit | 0d4a9d6b8740035346d098f5bc28ebca64f6cd4d (patch) | |
| tree | f52c9569509565e581b03b6e60fe32e611b79ad2 /tidal_dl_ng/worker.py | |
| parent | 82a8fe96aa08903919a90a76030bacba9f93b8e0 (diff) | |
| download | tidal-dl-ng-0d4a9d6b8740035346d098f5bc28ebca64f6cd4d.tar.gz | |
🌟 Re-add all project files.
Diffstat (limited to 'tidal_dl_ng/worker.py')
| -rw-r--r-- | tidal_dl_ng/worker.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tidal_dl_ng/worker.py b/tidal_dl_ng/worker.py new file mode 100644 index 0000000..84d5ac3 --- /dev/null +++ b/tidal_dl_ng/worker.py @@ -0,0 +1,31 @@ +from PySide6 import QtCore + + +# Taken from https://www.pythonguis.com/tutorials/multithreading-pyside6-applications-qthreadpool/ +class Worker(QtCore.QRunnable): + """ + Worker thread + + Inherits from QRunnable to handler worker thread setup, signals and wrap-up. + + :param callback: The function callback to run on this worker thread. Supplied args and + kwargs will be passed through to the runner. + :type callback: function + :param args: Arguments to pass to the callback function + :param kwargs: Keywords to pass to the callback function + + """ + + def __init__(self, fn, *args, **kwargs): + super().__init__() + # Store constructor arguments (re-used for processing) + self.fn = fn + self.args = args + self.kwargs = kwargs + + @QtCore.Slot() # QtCore.Slot + def run(self): + """ + Initialise the runner function with passed args, kwargs. + """ + self.fn(*self.args, **self.kwargs) |
