-
Notifications
You must be signed in to change notification settings - Fork 0
/
SuttonKioskTest2.py
163 lines (134 loc) · 5.6 KB
/
SuttonKioskTest2.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
from PyQt5.QtCore import Qt
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QGridLayout, QLabel, QLineEdit, QTextEdit, QWidget
from PyQt5.QtWidgets import (QApplication, QGridLayout, QLayout, QLineEdit,
QSizePolicy, QToolButton, QWidget)
from PyQt5.QtWidgets import QMainWindow, QPushButton, QWidget
import sys
from PyQt5.QtWidgets import QApplication
print ("Constructing an app")
app = QApplication(sys.argv)
class BackButton (QToolButton):
def __init__(self,goBack, parent=None):
super(BackButton, self).__init__(parent)
self.goBack = goBack
self.setText("Go Back")
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
def sizeHint(self):
size = super(BackButton, self).sizeHint()
size.setHeight(size.height() + 20)
size.setWidth(max(size.width(), size.height()))
return size
def mousePressEvent(self, event):
self.goBack()
class SchoolClass (QToolButton):
def __init__(self, name, students, parent=None):
super(SchoolClass, self).__init__(parent)
self.name = name
self.students = students
self.setText(name)
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
def sizeHint(self):
size = super(SchoolClass, self).sizeHint()
size.setHeight(size.height() + 20)
size.setWidth(max(size.width(), size.height()))
return size
def mousePressEvent(self, event):
self.studentListWindow = StudentListWindow()
self.studentListWindow.start(self.students, lambda: getSKInstance().startClassListWindow())
getSKInstance().setCentralWidget(self.studentListWindow)
class Student (QToolButton):
def __init__(self, name, parent=None):
super(Student, self).__init__(parent)
self.name = name
self.setText(name)
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
def sizeHint(self):
size = super(Student, self).sizeHint()
size.setHeight(size.height() + 20)
size.setWidth(max(size.width(), size.height()))
return size
def mousePressEvent(self, event):
pass
seanStudent = Student("Sean")
danaStudent = Student("Dana")
willStudent = Student("Will")
brookeStudent = Student("Brooke")
calcClass = SchoolClass("APCalc", [seanStudent, danaStudent])
statsClass = SchoolClass("APStats", [willStudent, brookeStudent])
variableClassList = [calcClass, statsClass]
class ClassListWindow(QWidget):
def __init__(self, parent=None):
super(ClassListWindow, self).__init__(parent)
self.verticalPosition = 50
def start(self, listOfClasses):
mainLayout = QGridLayout()
for myClass in listOfClasses:
print myClass.name
mainLayout.addWidget(myClass, 50, self.verticalPosition)
self.verticalPosition = self.verticalPosition + 50
self.setLayout(mainLayout)
self.setWindowTitle("ClassListWindow")
class StudentListWindow(QWidget):
def __init__(self, parent=None):
super(StudentListWindow, self).__init__(parent)
self.verticalPosition = 50
def start(self, listOfStudents, goBack):
mainLayout = QGridLayout()
self.backButton = BackButton(goBack)
mainLayout.addWidget(self.backButton, 50, self.verticalPosition)
self.verticalPosition = self.verticalPosition + 50
for student in listOfStudents:
mainLayout.addWidget(student, 50, self.verticalPosition)
self.verticalPosition = self.verticalPosition + 50
self.setLayout(mainLayout)
self.setWindowTitle("StudentListWindow")
class SuttonKioskMainWindow(QMainWindow):
def __init__(self, parent=None):
super(SuttonKioskMainWindow, self).__init__(parent)
print ("IN Sutton Kiosk test constructor")
self.setGeometry(0, 0, 320, 480)
self.setFixedSize(320, 480)
self.classList = variableClassList
self.startClassListWindow()
def startClassListWindow(self):
self.classListWindow = ClassListWindow(self)
self.setWindowTitle("ClassList")
self.classListWindow.start(self.classList)
self.setCentralWidget(self.classListWindow)
self.show()
"""def startStudentListWindow(self, schoolClass):
self.StudentListWindow = StudentListWindow(self)
print "IN startStudentListWindow"
for student in schoolClass.students:
print student.name
print
self.StudentListWindow.addStudents(schoolClass.students)
self.setWindowTitle("StudentList")
self.setCentralWidget(self.StudentListWindow)
self.StudentListWindow.backButton.clicked.connect(lambda: self.startClassListWindow(self.classList))
self.show()
def startClassListWindow(self, classList):
print "Starting Class LIst WIndow"
self.classListWindow = ClassListWindow(self)
self.setWindowTitle("ClassList")
self.setCentralWidget(self.classListWindow)
self.addClasses(classList)
self.show()
def addClasses(self, classList):
for myClass in classList:
button = self.classListWindow.makeClassButton(myClass)
#print myClass.name
print "In addClasses"
for student in myClass.students:
print student.name
print
button.clicked.connect(lambda: self.startStudentListWindow(myClass))"""
instance = SuttonKioskMainWindow()
def getSKInstance():
print "in get Instance"
return instance
if __name__ == '__main__':
suttonKioskMainWindow = getSKInstance()
suttonKioskMainWindow.show()
sys.exit(app.exec_())