-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
137 lines (106 loc) · 4.92 KB
/
main.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 14 10:45:15 2019
@author: U724965
"""
import sys
import common
import image_analyzer
import image_crop
import image_exposure
import image_sort
from PyQt5.QtWidgets import QApplication, QMessageBox
from functools import partial
# The manager of windows and what happens when Next and Back button are pressed
class Manager:
def __init__(self):
self.first = image_sort.ImageSort()
self.second = image_crop.ImageCrop()
self.third = image_exposure.ImageExposure()
self.fourth = image_analyzer.ImageAnalyze()
self.first.show()
self.first.pushButton_6.clicked.connect(partial(self.function, "gotoCrop"))
self.second.pushButton_5.clicked.connect(partial(self.function, "gotoExposure"))
self.third.pushButton_5.clicked.connect(partial(self.function, "gotoAnalysis"))
self.fourth.pushButton_2.clicked.connect(partial(self.function, "finishProgram"))
self.second.pushButton_4.clicked.connect(partial(self.function, "backToSort"))
self.third.pushButton_4.clicked.connect(partial(self.function, "backToCrop"))
self.fourth.pushButton_1.clicked.connect(partial(self.function, "backToExposure"))
def function(self, task):
if task == "gotoCrop":
for label in [self.second.label_1, self.second.label_2, self.second.label_3,
self.second.label_4, self.second.label_5, self.second.label_6]:
label.clear()
self.second.refresh = False
self.second.formCall = False
self.second.pushButton_2.setEnabled(False)
self.second.pushButton_3.setEnabled(False)
self.second.pushButton_1.setText("Show Images")
self.first.click6()
if common.show_message_btn1:
self.second.source_directory = self.first.source_directory
self.second.destination_directory = self.first.destination_directory
self.second.curr_dir_source = self.first.curr_dir_source
self.second.curr_dir_destination = self.first.curr_dir_destination
self.second.show()
if task == "gotoExposure":
for label in [self.third.label_1, self.third.label_2, self.third.label_3,
self.third.label_4, self.third.label_5, self.third.label_6]:
label.clear()
self.second.click5()
if common.show_message_btn1:
self.third.source_directory = self.second.source_directory
self.third.destination_directory = self.second.destination_directory
self.third.curr_dir_source = self.second.curr_dir_source
self.third.curr_dir_destination = self.second.curr_dir_destination
self.third.show()
if task == "gotoAnalysis":
self.third.click7()
if common.show_message_btn1:
self.fourth.source_directory = self.third.source_directory
self.fourth.destination_directory = self.third.destination_directory
self.fourth.curr_dir_source = self.third.curr_dir_source
self.fourth.curr_dir_destination = self.third.curr_dir_destination
self.fourth.show()
self.fourth.tree_update()
if task == "finishProgram":
self.first.close()
self.second.close()
self.third.close()
self.fourth.close()
if task == "backToSort":
self.first.listWidget.clear()
self.second.click4()
if common.show_message_btn1:
self.first.show()
if task == "backToCrop":
for label in [self.second.label_1, self.second.label_2, self.second.label_3,
self.second.label_4, self.second.label_5, self.second.label_6]:
label.clear()
self.second.pushButton_1.setText("Show Images")
self.second.refresh = False
self.second.formCall = False
self.second.pushButton_2.setEnabled(False)
self.second.pushButton_3.setEnabled(False)
self.third.click6()
if common.show_message_btn1:
self.second.show()
if task == "backToExposure":
for label in [self.third.label_1, self.third.label_2, self.third.label_3,
self.third.label_4, self.third.label_5, self.third.label_6]:
label.clear()
self.fourth.click1()
if common.show_message_btn1:
self.third.show()
def catch_exceptions(t, val, tb):
QMessageBox.critical(None,
"An exception was raised",
"Exception type: {}".format(t))
old_hook(t, val, tb)
old_hook = sys.excepthook
sys.excepthook = catch_exceptions
def main():
app = QApplication(sys.argv)
manager = Manager()
app.exec_()
if __name__ == '__main__': main()