-
Notifications
You must be signed in to change notification settings - Fork 0
/
loader_thread.py
34 lines (23 loc) · 965 Bytes
/
loader_thread.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import debugpy
from PySide6.QtCore import Qt, QThread, Signal
from PySide6.QtWidgets import QProgressDialog
class LoaderThread(QThread):
finished = Signal()
def __init__(self, parent) -> None:
super().__init__(parent)
self.filenames: list[str] = []
def run(self):
# debugpy.debug_this_thread()
from mainwindow import MainWindow
main_window = self.parent()
if isinstance(main_window, MainWindow) and len(self.filenames) > 0:
progress = QProgressDialog(
"Scanning files...", "Cancel", 0, len(self.filenames), main_window
)
progress.setWindowModality(Qt.WindowModality.WindowModal)
for i, filename in enumerate(self.filenames):
progress.setValue(i)
if progress.wasCanceled():
break
main_window.load_file(filename)
progress.setValue(len(self.filenames))