-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGUI.py
110 lines (94 loc) · 3.11 KB
/
GUI.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
import sys
sys.path.append('UI/MainUI')
sys.path.append('Classes')
from PyQt4 import QtGui
from PyQt4.QtGui import QPixmap
import MainUI
from EEG_reader import EEGReader
from PyQt4.QtCore import QTimer
class App(QtGui.QMainWindow, MainUI.Ui_BCARM):
labelsList = []
reader = None
timer = QTimer()
breakTime = 20
def __init__(self):
super(self.__class__, self).__init__()
self.setupUi(self)
self.labelsList = [[self.A, self.B, self.C],
[self.D, self.E, self.F],
[self.G, self.H, self.I]]
self.reader = EEGReader();
# connect signals with their corresponding slots
self.reader.flashOn.connect(self.flashOn)
self.reader.flashOff.connect(self.flashOff)
self.reader.markAsNormal.connect(self.markAsNormal)
self.reader.markAsTarget.connect(self.markAsTarget)
self.reader.brk.connect(self.brk)
self.timer.timeout.connect(self.tick)
def showFullScreen(self):
super(self.__class__, self).showFullScreen()
self.reader.start()
def getRow(self, c):
''' given a character c, returns the row including the character in the screen '''
code = c - ord('A')
return code / 3
def getCol(self, c):
''' given a character c, returns the column including the character in the screen '''
code = c - ord('A')
return code % 3
def markAsNormal(self, c):
x = self.getRow(c)
y = self.getCol(c)
self.labelsList[x][y].setStyleSheet("color: rgb(61, 61, 61)")
font = QtGui.QFont()
font.setPointSize(96)
self.labelsList[x][y].setFont(font)
def markAsTarget(self, c):
x = self.getRow(c)
y = self.getCol(c)
self.labelsList[x][y].setStyleSheet("color: rgb(255, 0, 0)")
font = QtGui.QFont()
font.setPointSize(128)
self.labelsList[x][y].setFont(font)
def flashOn(self, rc):
dx, dy = 0, 1
x, y = rc, 0
if (rc > 2):
dx, dy = 1, 0
x, y = 0, rc - 3
for i in range(3):
self.labelsList[x][y].setStyleSheet("color: rgb(255, 255, 255)")
font = QtGui.QFont()
font.setPointSize(128)
self.labelsList[x][y].setFont(font)
x = x + dx
y = y + dy
def flashOff(self, rc):
dx, dy = 0, 1
x, y = rc, 0
if (rc > 2):
dx, dy = 1, 0
x, y = 0, rc - 3
for i in range(3):
self.labelsList[x][y].setStyleSheet("color: rgb(61, 61, 61)")
font = QtGui.QFont()
font.setPointSize(96)
self.labelsList[x][y].setFont(font)
x = x + dx
y = y + dy
def brk(self):
self.timer.start(1000)
def tick(self):
print self.breakTime
self.breakTime -= 1
if (self.breakTime == 0):
self.timer.stop()
self.breakTime = 120
self.reader.startEpoch()
def main():
app = QtGui.QApplication(sys.argv)
form = App();
form.showFullScreen();
app.exec_();
if __name__ == '__main__':
main()