2019-02-02 11:27:38 +01:00
|
|
|
import os
|
|
|
|
import time
|
|
|
|
|
|
|
|
from PyQt5.QtWidgets import QDialog
|
|
|
|
from PyQt5 import uic
|
|
|
|
|
|
|
|
|
|
|
|
class ProgressDialog(QDialog):
|
2019-02-10 17:21:41 +01:00
|
|
|
"""Displays a progress dialog while a thread is running. When the thread
|
|
|
|
stops, the dialog disappears.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
thread (thread) the thread to execute."""
|
2019-02-02 11:27:38 +01:00
|
|
|
def __init__(self, thread):
|
|
|
|
super(ProgressDialog, self).__init__()
|
|
|
|
# Load the UI file to get the dialogs layout.
|
|
|
|
dir_path = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
ui_path = os.path.join(dir_path + '/static/UI/Progress.ui')
|
|
|
|
uic.loadUi(ui_path, self)
|
|
|
|
self.thread = thread
|
|
|
|
self.thread.finished.connect(self.close)
|
|
|
|
self.thread.start()
|
|
|
|
|
|
|
|
def reject(self):
|
|
|
|
self.thread.stop()
|
|
|
|
super().reject()
|