-
Notifications
You must be signed in to change notification settings - Fork 2
/
mainCV.py
90 lines (75 loc) · 2.87 KB
/
mainCV.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
################################################################################
##
## Created by: NeuralSIGHT Team
## Give execution permission to this file with chmod -x mainCV.py
## Run this file as ./mainCV.py
################################################################################
import sys
from PyQt5 import QtCore
from PyQt5.QtGui import QColor
from PyQt5.QtWidgets import *
from splash_screen import Ui_SplashScreen
from main_windowCV import Ui_MainWindow
counter = 0
class MainWindow(QMainWindow):
"""Main Class responsible for handling main window."""
def __init__(self):
QMainWindow.__init__(self)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.center()
def center(self):
"""Set main window to center position."""
setGeometry = self.frameGeometry()
centerGeometry = QDesktopWidget().availableGeometry().center()
setGeometry.moveCenter(centerGeometry)
self.move(setGeometry.topLeft())
class SplashScreen(QMainWindow):
def __init__(self):
"""Class resposible for handling splash screen effect
before loading main window.
"""
QMainWindow.__init__(self)
self.ui = Ui_SplashScreen()
self.ui.setupUi(self)
self.setWindowFlag(QtCore.Qt.FramelessWindowHint)
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
self.shadow = QGraphicsDropShadowEffect(self)
self.shadow.setBlurRadius(20)
self.shadow.setXOffset(0)
self.shadow.setYOffset(0)
self.shadow.setColor(QColor(0, 0, 0, 60))
self.ui.dropShadowFrame.setGraphicsEffect(self.shadow)
self.timer = QtCore.QTimer()
self.timer.timeout.connect(self.progress)
self.timer.start(45) # Timer in milisecond
self.ui.label_description.setText("Breast Cancer Early Detection System")
self.ui.label_loading.setText("Please Wait")
QtCore.QTimer.singleShot(
1500, lambda: self.ui.label_loading.setText("Loading Assets")
)
QtCore.QTimer.singleShot(
3000, lambda: self.ui.label_loading.setText("Loading User Interface")
)
self.center()
self.show()
def progress(self):
"""Splash screen progress bar functionality."""
global counter
self.ui.progressBar.setValue(counter)
if counter > 100:
self.timer.stop()
self.main = MainWindow()
self.main.show()
self.close()
counter += 1
def center(self):
"""Set splash screen to center position."""
setGeometry = self.frameGeometry()
centerGeometry = QDesktopWidget().availableGeometry().center()
setGeometry.moveCenter(centerGeometry)
self.move(setGeometry.topLeft())
if __name__ == "__main__":
app = QApplication(sys.argv)
window = SplashScreen()
sys.exit(app.exec_())