-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
74 lines (61 loc) · 2.55 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
from PyQt5 import QtWidgets
import sys
from sql.sql import Sql
from mouse.mouse import Mouse
from parameters.parameters import Parameters
from task.taskSettings import TaskSettings
from task.taskMain import TaskMain
# last-3) threads
# last-2) fix mySql timezone?
# last-1) figure out slot decorators and lambdas (more pythonic code?)
# last) follow pep8, fix naming convention
class Main:
def __init__(self):
self.sqlUi = QtWidgets.QMainWindow()
self.sql = Sql(self.sqlUi)
self.sql.mouse_toggled.connect(self.show_mouse)
self.sql.parameters_toggled.connect(self.show_parameters)
self.sql.task_toggled.connect(self.show_task_settings)
attribute_placeholder = 1
self.mouseUi = QtWidgets.QMainWindow()
self.mouse = attribute_placeholder
self.parametersUi = QtWidgets.QMainWindow()
self.parameters = attribute_placeholder
self.taskSettingsUi = QtWidgets.QMainWindow()
self.task_settings = attribute_placeholder
self.taskMainUi = QtWidgets.QWidget()
self.task_main = attribute_placeholder
def show_sql(self):
self.mouseUi.close()
self.parametersUi.close()
self.taskSettingsUi.close()
self.sqlUi.show()
def show_mouse(self, sql_connection):
self.mouse = Mouse(self.mouseUi, sql_connection)
self.mouse.back_pressed.connect(self.show_sql)
self.sqlUi.hide()
self.mouseUi.show()
def show_parameters(self, sql_connection):
self.parameters = Parameters(self.parametersUi, sql_connection)
self.parameters.back_pressed.connect(self.show_sql)
self.sqlUi.hide()
self.parametersUi.show()
def show_plots(self):
pass
def show_task_settings(self, sql_connection):
self.task_settings = TaskSettings(self.taskSettingsUi, sql_connection)
self.task_settings.back_pressed.connect(self.show_sql)
self.task_settings.open_task.connect(self.show_task)
self.sqlUi.hide()
self.taskSettingsUi.show()
def show_task(self, session_num, session_suffix, sql_connection, com_connection,
cage_number, mouse_number, parameters, save_data):
self.task_main = TaskMain(self.taskMainUi, session_num, session_suffix, sql_connection,
com_connection, cage_number, mouse_number, parameters, save_data)
self.taskSettingsUi.hide()
self.taskMainUi.show()
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
main = Main()
main.show_sql()
sys.exit(app.exec_())