Skip to content

Commit

Permalink
feat: main window design updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Yejining committed Feb 12, 2020
1 parent e8425ef commit fb32231
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 26 deletions.
66 changes: 41 additions & 25 deletions gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self):
self.matrix = []


class Card:
class CardSetting:
def __init__(self):
self.width = 0
self.height = 0
Expand Down Expand Up @@ -132,6 +132,20 @@ def setupUi(self, MainWindow):
self.pushButton_seqsize.setObjectName("pushButton_seqsize")
self.horizontalLayout_6.addWidget(self.pushButton_seqsize)
self.verticalLayout_3.addLayout(self.horizontalLayout_6)
self.horizontalLayout_9 = QtWidgets.QHBoxLayout()
self.horizontalLayout_9.setObjectName("horizontalLayout_9")
self.label_seqtimer = QtWidgets.QLabel(self.box_sequence)
self.label_seqtimer.setObjectName("label_seqtimer")
self.horizontalLayout_9.addWidget(self.label_seqtimer)
spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_9.addItem(spacerItem3)
self.lineEdit_seqtimer = QtWidgets.QLineEdit(self.box_sequence)
self.lineEdit_seqtimer.setObjectName("lineEdit_seqtimer")
self.horizontalLayout_9.addWidget(self.lineEdit_seqtimer)
self.label_sequnit = QtWidgets.QLabel(self.box_sequence)
self.label_sequnit.setObjectName("label_sequnit")
self.horizontalLayout_9.addWidget(self.label_sequnit)
self.verticalLayout_3.addLayout(self.horizontalLayout_9)
self.box_detailed = QtWidgets.QGroupBox(self.box_sequence)
self.box_detailed.setObjectName("box_detailed")
self.verticalLayout_4 = QtWidgets.QVBoxLayout(self.box_detailed)
Expand Down Expand Up @@ -174,8 +188,8 @@ def setupUi(self, MainWindow):
self.label_boardsize = QtWidgets.QLabel(self.box_game)
self.label_boardsize.setObjectName("label_boardsize")
self.horizontalLayout_4.addWidget(self.label_boardsize)
spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_4.addItem(spacerItem3)
spacerItem4 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_4.addItem(spacerItem4)
self.lineEdit_boardsizen = QtWidgets.QLineEdit(self.box_game)
self.lineEdit_boardsizen.setObjectName("lineEdit_boardsizen")
self.horizontalLayout_4.addWidget(self.lineEdit_boardsizen)
Expand Down Expand Up @@ -279,8 +293,8 @@ def setupUi(self, MainWindow):
self.label_width = QtWidgets.QLabel(self.box_card)
self.label_width.setObjectName("label_width")
self.horizontalLayout.addWidget(self.label_width)
spacerItem4 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem4)
spacerItem5 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem5)
self.lineEdit_width = QtWidgets.QLineEdit(self.box_card)
self.lineEdit_width.setObjectName("lineEdit_width")
self.horizontalLayout.addWidget(self.lineEdit_width)
Expand All @@ -293,8 +307,8 @@ def setupUi(self, MainWindow):
self.label_height = QtWidgets.QLabel(self.box_card)
self.label_height.setObjectName("label_height")
self.horizontalLayout_10.addWidget(self.label_height)
spacerItem5 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_10.addItem(spacerItem5)
spacerItem6 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_10.addItem(spacerItem6)
self.lineEdit_height = QtWidgets.QLineEdit(self.box_card)
self.lineEdit_height.setObjectName("lineEdit_height")
self.horizontalLayout_10.addWidget(self.lineEdit_height)
Expand All @@ -307,8 +321,8 @@ def setupUi(self, MainWindow):
self.label_marginh = QtWidgets.QLabel(self.box_card)
self.label_marginh.setObjectName("label_marginh")
self.horizontalLayout_11.addWidget(self.label_marginh)
spacerItem6 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_11.addItem(spacerItem6)
spacerItem7 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_11.addItem(spacerItem7)
self.lineEdit_marginh = QtWidgets.QLineEdit(self.box_card)
self.lineEdit_marginh.setObjectName("lineEdit_marginh")
self.horizontalLayout_11.addWidget(self.lineEdit_marginh)
Expand All @@ -321,8 +335,8 @@ def setupUi(self, MainWindow):
self.label_marginv = QtWidgets.QLabel(self.box_card)
self.label_marginv.setObjectName("label_marginv")
self.horizontalLayout_12.addWidget(self.label_marginv)
spacerItem7 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_12.addItem(spacerItem7)
spacerItem8 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_12.addItem(spacerItem8)
self.lineEdit_marginv = QtWidgets.QLineEdit(self.box_card)
self.lineEdit_marginv.setObjectName("lineEdit_marginv")
self.horizontalLayout_12.addWidget(self.lineEdit_marginv)
Expand All @@ -336,8 +350,8 @@ def setupUi(self, MainWindow):
self.label_dwell = QtWidgets.QLabel(self.box_game)
self.label_dwell.setObjectName("label_dwell")
self.horizontalLayout_5.addWidget(self.label_dwell)
spacerItem8 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_5.addItem(spacerItem8)
spacerItem9 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_5.addItem(spacerItem9)
self.lineEdit_dwell = QtWidgets.QLineEdit(self.box_game)
self.lineEdit_dwell.setObjectName("lineEdit_dwell")
self.horizontalLayout_5.addWidget(self.lineEdit_dwell)
Expand All @@ -364,8 +378,8 @@ def setupUi(self, MainWindow):
self.label_bubble = QtWidgets.QLabel(self.frame_bubble)
self.label_bubble.setObjectName("label_bubble")
self.hLayout_bubble.addWidget(self.label_bubble)
spacerItem9 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.hLayout_bubble.addItem(spacerItem9)
spacerItem10 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.hLayout_bubble.addItem(spacerItem10)
self.radioButton_on = QtWidgets.QRadioButton(self.frame_bubble)
self.radioButton_on.setChecked(True)
self.radioButton_on.setObjectName("radioButton_on")
Expand Down Expand Up @@ -421,8 +435,8 @@ def setupUi(self, MainWindow):
self.pushButton_apply.setObjectName("pushButton_apply")
self.hLayout_setting.addWidget(self.pushButton_apply)
self.gridLayout_6.addLayout(self.hLayout_setting, 1, 0, 1, 1)
spacerItem10 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.gridLayout_6.addItem(spacerItem10, 2, 0, 1, 1)
spacerItem11 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.gridLayout_6.addItem(spacerItem11, 2, 0, 1, 1)
self.gridLayout_2.addWidget(self.box_setting, 0, 0, 1, 1)
self.stack.addWidget(self.page_database)
self.page_shortcuts = QtWidgets.QWidget()
Expand All @@ -442,8 +456,8 @@ def setupUi(self, MainWindow):
self.label_shortcut1Name.setAlignment(QtCore.Qt.AlignCenter)
self.label_shortcut1Name.setObjectName("label_shortcut1Name")
self.hLayout_shortcut1.addWidget(self.label_shortcut1Name)
spacerItem11 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.hLayout_shortcut1.addItem(spacerItem11)
spacerItem12 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.hLayout_shortcut1.addItem(spacerItem12)
self.label_shortcut1 = QtWidgets.QLabel(self.box_shortcuts)
self.label_shortcut1.setObjectName("label_shortcut1")
self.hLayout_shortcut1.addWidget(self.label_shortcut1)
Expand All @@ -455,17 +469,17 @@ def setupUi(self, MainWindow):
self.label_shortcut2Name.setAlignment(QtCore.Qt.AlignCenter)
self.label_shortcut2Name.setObjectName("label_shortcut2Name")
self.hLayout_shortcut2.addWidget(self.label_shortcut2Name)
spacerItem12 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.hLayout_shortcut2.addItem(spacerItem12)
spacerItem13 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.hLayout_shortcut2.addItem(spacerItem13)
self.label_shortcut2 = QtWidgets.QLabel(self.box_shortcuts)
self.label_shortcut2.setObjectName("label_shortcut2")
self.hLayout_shortcut2.addWidget(self.label_shortcut2)
self.vLayout_shortcuts.addLayout(self.hLayout_shortcut2)
self.pushButton_ok = QtWidgets.QPushButton(self.box_shortcuts)
self.pushButton_ok.setObjectName("pushButton_ok")
self.vLayout_shortcuts.addWidget(self.pushButton_ok)
spacerItem13 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.vLayout_shortcuts.addItem(spacerItem13)
spacerItem14 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.vLayout_shortcuts.addItem(spacerItem14)
self.gridLayout_5.addLayout(self.vLayout_shortcuts, 0, 0, 1, 1)
self.gridLayout_4.addWidget(self.box_shortcuts, 0, 0, 1, 1)
self.stack.addWidget(self.page_shortcuts)
Expand All @@ -492,6 +506,8 @@ def retranslateUi(self, MainWindow):
self.box_sequence.setTitle(_translate("MainWindow", "Sequence Setting"))
self.label_seqsize.setText(_translate("MainWindow", "Size:"))
self.pushButton_seqsize.setText(_translate("MainWindow", "Apply"))
self.label_seqtimer.setText(_translate("MainWindow", "Timer:"))
self.label_sequnit.setText(_translate("MainWindow", "second(s)"))
self.box_detailed.setTitle(_translate("MainWindow", "Sequence"))
self.box_game.setTitle(_translate("MainWindow", "Game Setting"))
self.label_boardsize.setText(_translate("MainWindow", "Size:"))
Expand All @@ -508,7 +524,7 @@ def retranslateUi(self, MainWindow):
self.label_marginv.setText(_translate("MainWindow", "Vertical Margin:"))
self.label_marginvpx.setText(_translate("MainWindow", "px"))
self.label_dwell.setText(_translate("MainWindow", "Dwell Timer:"))
self.label_dwellunit.setText(_translate("MainWindow", "second(s)"))
self.label_dwellunit.setText(_translate("MainWindow", "millisecond(s)"))
self.label_bubble.setText(_translate("MainWindow", "Gaze Visalizaition"))
self.radioButton_on.setText(_translate("MainWindow", "On"))
self.radioButton_off.setText(_translate("MainWindow", "Off"))
Expand Down Expand Up @@ -591,7 +607,7 @@ def initializeClass(self):
row.append(self.lineEdit_board44)
self.sequence.matrix.append(row)

self.card = Card()
self.card = CardSetting()
self.card.width = self.lineEdit_width
self.card.height = self.lineEdit_height
self.card.horizontal_margin = self.lineEdit_marginh
Expand Down
8 changes: 8 additions & 0 deletions src/input/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__(self,
checkBox_dbid,
lineEdit_pupiltimer,
lineEdit_seqsize,
lineEdit_seqtimer,
lineEdit_boardsizen,
lineEdit_boardsizem,
sequence,
Expand All @@ -42,6 +43,7 @@ def __init__(self,
self.checkBox_dbid = checkBox_dbid
self.lineEdit_pupiltimer = lineEdit_pupiltimer
self.lineEdit_seqsize = lineEdit_seqsize
self.lineEdit_seqtimer = lineEdit_seqtimer
self.lineEdit_boardsizen = lineEdit_boardsizen
self.lineEdit_boardsizem = lineEdit_boardsizem
self.sequence = sequence
Expand All @@ -56,6 +58,8 @@ def is_all_filled_properly(self):
if pupil_timer.is_true: return pupil_timer
seqsize = self.is_seqsize_number()
if seqsize.is_true: return seqsize
seqtimer = self.is_seqtimer_number()
if seqtimer.is_true: return seqtimer
is_seq_filled = self.is_seq_filled()
if is_seq_filled.is_true: return is_seq_filled
boardsize = self.is_board_filled()
Expand All @@ -77,6 +81,10 @@ def is_seqsize_number(self):
if int(self.lineEdit_seqsize.displayText()) > 8: error.set_message("8 is Maximum Number!")
return error

def is_seqtimer_number(self):
error = is_value_number(self.lineEdit_seqtimer.displayText(), "Sequence Timer")
return error

def is_boardsize_number(self):
error = is_value_number(self.lineEdit_boardsizem.displayText(), "Row")
if int(self.lineEdit_boardsizem.displayText()) > 5: error.set_message("5 is Maximum Number!")
Expand Down
51 changes: 51 additions & 0 deletions src/input/parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from src.game.status import Status


class Parser:

def __init__(self, inputs):
self.inputs = inputs

def pupil_time(self):
return self.inputs.lineEdit_pupiltimer.displayText() * 1000

def sequence_time(self):
return self.inputs.lineEdit_seqtimer.displayText() * 1000

def dwell_time(self):
return self.inputs.lineEdit_dwell.displayText()

def width(self):
return self.inputs.card.width.displayText()

def height(self):
return self.inputs.card.height.displayText()

def horizontal_margin(self):
return self.inputs.card.horizontal_margin.displayText()

def vertical_margin(self):
return self.inputs.card.vertical_margin.displayText()

def get_time(self, status):
if status == Status.PUPIL:
return self.pupil_time()
elif status == Status.SEQUENCE:
return self.sequence_time()
elif status == Status.GAME:
return self.dwell_time()

def get_card_size(self):
width = self.width()
height = self.height()
return width, height

def get_margins(self):
horizontal_margin = self.horizontal_margin()
vertical_margin = self.vertical_margin()
return horizontal_margin, vertical_margin

def get_matrix_size(self):
n = self.inputs.lineEdit_boardsizen.displayText()
m = self.inputs.lineEdit_boardsizem.displayText()
return n, m
36 changes: 35 additions & 1 deletion ui/main.ui
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,40 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QLabel" name="label_seqtimer">
<property name="text">
<string>Timer:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_11">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_seqtimer"/>
</item>
<item>
<widget class="QLabel" name="label_sequnit">
<property name="text">
<string>second(s)</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="box_detailed">
<property name="title">
Expand Down Expand Up @@ -571,7 +605,7 @@
<item>
<widget class="QLabel" name="label_dwellunit">
<property name="text">
<string>second(s)</string>
<string>millisecond(s)</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit fb32231

Please sign in to comment.