|
|
|
@ -1,11 +1,15 @@
|
|
|
|
|
from PySide import QtGui, QtCore
|
|
|
|
|
|
|
|
|
|
from gamestate import QuestionAnswer
|
|
|
|
|
|
|
|
|
|
#class QuestionWindow(QtGui.QWidget):
|
|
|
|
|
class QuestionWindow(QtGui.QDialog):
|
|
|
|
|
def __init__(self, section, question, parent=None):
|
|
|
|
|
def __init__(self, players, section, qnumber, question, parent=None):
|
|
|
|
|
super(QuestionWindow, self).__init__(parent)
|
|
|
|
|
|
|
|
|
|
self.players = players
|
|
|
|
|
self.section = section
|
|
|
|
|
self.qnumber = qnumber
|
|
|
|
|
self.question = question
|
|
|
|
|
self.results = []
|
|
|
|
|
|
|
|
|
@ -53,3 +57,56 @@ class QuestionWindow(QtGui.QDialog):
|
|
|
|
|
print("question", e, e.key())
|
|
|
|
|
if e.key() == QtCore.Qt.Key_Escape:
|
|
|
|
|
self.close()
|
|
|
|
|
elif e.key() >= ord('1') and e.key() <= ord(str(len(self.players))):
|
|
|
|
|
player = self.players[e.key() - ord('1')]
|
|
|
|
|
qawin = QuestionAnswerWindow(player, self)
|
|
|
|
|
res = qawin.exec_()
|
|
|
|
|
if res == QuestionAnswerWindow.CORRECT:
|
|
|
|
|
print("Done!")
|
|
|
|
|
q = QuestionAnswer(self.section, self.qnumber, player, len(self.results)+1, True)
|
|
|
|
|
self.results.append(q)
|
|
|
|
|
self.accept()
|
|
|
|
|
elif res == QuestionAnswerWindow.WRONG:
|
|
|
|
|
q = QuestionAnswer(self.section, self.qnumber, player, len(self.results)+1, False)
|
|
|
|
|
self.results.append(q)
|
|
|
|
|
|
|
|
|
|
class QuestionAnswerWindow(QtGui.QDialog):
|
|
|
|
|
CORRECT = 1
|
|
|
|
|
WRONG = 2
|
|
|
|
|
OOPS = 3
|
|
|
|
|
|
|
|
|
|
def __init__(self, player, parent=None):
|
|
|
|
|
super(QuestionAnswerWindow, self).__init__(parent)
|
|
|
|
|
self.player = player
|
|
|
|
|
|
|
|
|
|
self._setupGui()
|
|
|
|
|
|
|
|
|
|
# move window to bottom right of screen
|
|
|
|
|
g = QtGui.QApplication.desktop().screenGeometry()
|
|
|
|
|
self.show()
|
|
|
|
|
cPos = self.rect()
|
|
|
|
|
self.move(g.width() - cPos.width(), g.height() - cPos.height())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _setupGui(self):
|
|
|
|
|
self.layout = QtGui.QVBoxLayout()
|
|
|
|
|
|
|
|
|
|
self.plabel = QtGui.QLabel(self.player.name)
|
|
|
|
|
self.plabel.setStyleSheet("QLabel { font-size: 60px; }")
|
|
|
|
|
self.layout.addWidget(self.plabel, alignment=QtCore.Qt.AlignCenter)
|
|
|
|
|
|
|
|
|
|
btnbox = QtGui.QHBoxLayout()
|
|
|
|
|
right = QtGui.QPushButton("Correct")
|
|
|
|
|
right.clicked.connect(lambda: self.done(self.CORRECT))
|
|
|
|
|
btnbox.addWidget(right)
|
|
|
|
|
wrong = QtGui.QPushButton("Wrong")
|
|
|
|
|
wrong.clicked.connect(lambda: self.done(self.WRONG))
|
|
|
|
|
btnbox.addWidget(wrong)
|
|
|
|
|
btnbox.addStretch()
|
|
|
|
|
oops = QtGui.QPushButton("Oops")
|
|
|
|
|
oops.clicked.connect(lambda: self.done(self.OOPS))
|
|
|
|
|
btnbox.addWidget(oops)
|
|
|
|
|
self.layout.addLayout(btnbox)
|
|
|
|
|
|
|
|
|
|
self.setLayout(self.layout)
|
|
|
|
|
|
|
|
|
|