Commit 4fd67aa6 authored by Agrigor's avatar Agrigor

Timer added in question dialog and now it's possible to have negative points

parent 1c9df158
...@@ -63,6 +63,9 @@ ...@@ -63,6 +63,9 @@
<property name="correctionMode"> <property name="correctionMode">
<enum>QAbstractSpinBox::CorrectToNearestValue</enum> <enum>QAbstractSpinBox::CorrectToNearestValue</enum>
</property> </property>
<property name="minimum">
<number>-9900</number>
</property>
<property name="maximum"> <property name="maximum">
<number>9900</number> <number>9900</number>
</property> </property>
...@@ -79,6 +82,9 @@ ...@@ -79,6 +82,9 @@
<property name="correctionMode"> <property name="correctionMode">
<enum>QAbstractSpinBox::CorrectToNearestValue</enum> <enum>QAbstractSpinBox::CorrectToNearestValue</enum>
</property> </property>
<property name="minimum">
<number>-9900</number>
</property>
<property name="maximum"> <property name="maximum">
<number>9900</number> <number>9900</number>
</property> </property>
...@@ -95,6 +101,9 @@ ...@@ -95,6 +101,9 @@
<property name="correctionMode"> <property name="correctionMode">
<enum>QAbstractSpinBox::CorrectToNearestValue</enum> <enum>QAbstractSpinBox::CorrectToNearestValue</enum>
</property> </property>
<property name="minimum">
<number>-9900</number>
</property>
<property name="maximum"> <property name="maximum">
<number>9900</number> <number>9900</number>
</property> </property>
...@@ -111,6 +120,9 @@ ...@@ -111,6 +120,9 @@
<property name="correctionMode"> <property name="correctionMode">
<enum>QAbstractSpinBox::CorrectToNearestValue</enum> <enum>QAbstractSpinBox::CorrectToNearestValue</enum>
</property> </property>
<property name="minimum">
<number>-9900</number>
</property>
<property name="maximum"> <property name="maximum">
<number>9900</number> <number>9900</number>
</property> </property>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>Dialog</class> <class>Question</class>
<widget class="QDialog" name="Dialog"> <widget class="QDialog" name="Question">
<property name="windowModality"> <property name="windowModality">
<enum>Qt::NonModal</enum> <enum>Qt::NonModal</enum>
</property> </property>
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Dialog</string> <string>Question</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
...@@ -31,6 +31,19 @@ p, li { white-space: pre-wrap; } ...@@ -31,6 +31,19 @@ p, li { white-space: pre-wrap; }
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QLCDNumber" name="TimeLCD">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="numDigits">
<number>2</number>
</property>
<property name="segmentStyle">
<enum>QLCDNumber::Flat</enum>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>
......
...@@ -24,6 +24,7 @@ IP = "127.0.0.1" ...@@ -24,6 +24,7 @@ IP = "127.0.0.1"
PLAYERS_MAX = 4 PLAYERS_MAX = 4
CATEGORIES_MAX = 5 CATEGORIES_MAX = 5
QUESTION_LENGTH_MAX = 1024 * 1024 QUESTION_LENGTH_MAX = 1024 * 1024
TIMEOUT = 60
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~ CLASS DEFINITION ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~ CLASS DEFINITION ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...@@ -341,8 +342,20 @@ class QuestionGUI(QDialog): ...@@ -341,8 +342,20 @@ class QuestionGUI(QDialog):
QDialog.__init__(self) QDialog.__init__(self)
self.UI_Question = loadUi("GUIs/question.ui", self) self.UI_Question = loadUi("GUIs/question.ui", self)
self.UI_Question.QuestionText.setHtml(text) self.UI_Question.QuestionText.setHtml(text)
self.UI_Question.TimeLCD.display(TIMEOUT)
self.time = TIMEOUT
self.timer = QTimer(self)
self.timer.timeout.connect(self.timeHandler)
self.timer.start(1000)
self.UI_Question.show() self.UI_Question.show()
def timeHandler(self):
if self.time > 0:
self.time -= 1
else:
self.time = 0
self.UI_Question.TimeLCD.display(self.time)
class MainGUI(QMainWindow): class MainGUI(QMainWindow):
def __init__(self): def __init__(self):
......
import sys import sys
from PyQt4 import QtGui, QtCore from PyQt4 import QtGui, QtCore
class Main(QtGui.QMainWindow): class Main(QtGui.QMainWindow):
def __init__(self): def __init__(self):
...@@ -17,18 +18,18 @@ class Main(QtGui.QMainWindow): ...@@ -17,18 +18,18 @@ class Main(QtGui.QMainWindow):
self.time = QtGui.QTimeEdit(self) self.time = QtGui.QTimeEdit(self)
self.timer.timeout.connect(self.Time) self.timer.timeout.connect(self.Time)
self.set = QtGui.QPushButton("Set",self) self.set = QtGui.QPushButton("Set", self)
self.set.clicked.connect(self.Set) self.set.clicked.connect(self.Set)
self.stop = QtGui.QPushButton("Stop",self) self.stop = QtGui.QPushButton("Stop", self)
self.stop.clicked.connect(lambda: self.timer.stop()) self.stop.clicked.connect(lambda: self.timer.stop())
grid = QtGui.QGridLayout(self) grid = QtGui.QGridLayout(self)
grid.addWidget(self.lcd,3,0) grid.addWidget(self.lcd, 3, 0)
grid.addWidget(self.time,0,0) grid.addWidget(self.time, 0, 0)
grid.addWidget(self.set,1,0) grid.addWidget(self.set, 1, 0)
grid.addWidget(self.stop,2,0) grid.addWidget(self.stop, 2, 0)
centralwidget = QtGui.QWidget() centralwidget = QtGui.QWidget()
...@@ -37,12 +38,12 @@ class Main(QtGui.QMainWindow): ...@@ -37,12 +38,12 @@ class Main(QtGui.QMainWindow):
centralwidget.setLayout(grid) centralwidget.setLayout(grid)
#---------Window settings -------------------------------- #---------Window settings --------------------------------
self.setGeometry(300,300,280,170) self.setGeometry(300, 300, 280, 170)
def Set(self): def Set(self):
global t,h,m,s global t, h, m, s
t = self.time.time() t = self.time.time()
self.lcd.display(t.toString()) self.lcd.display(t.toString())
...@@ -53,10 +54,10 @@ class Main(QtGui.QMainWindow): ...@@ -53,10 +54,10 @@ class Main(QtGui.QMainWindow):
s = t.second() s = t.second()
def Time(self): def Time(self):
global t,h,m,s global t, h, m, s
if s > 0: if s > 0:
s -=1 s -= 1
else: else:
if m > 0: if m > 0:
m -= 1 m -= 1
...@@ -67,16 +68,17 @@ class Main(QtGui.QMainWindow): ...@@ -67,16 +68,17 @@ class Main(QtGui.QMainWindow):
s = 59 s = 59
else: else:
self.timer.stop() self.timer.stop()
stop = QtGui.QMessageBox.warning(self,"Time is up","Time is up") stop = QtGui.QMessageBox.warning(self, "Time is up", "Time is up")
time = ("{0}:{1}:{2}".format(h,m,s)) time = ("{0}:{1}:{2}".format(h, m, s))
self.lcd.setDigitCount(len(time)) self.lcd.setDigitCount(len(time))
self.lcd.display(time) self.lcd.display(time)
def main(): def main():
app = QtGui.QApplication(sys.argv) app = QtGui.QApplication(sys.argv)
main= Main() main = Main()
main.show() main.show()
sys.exit(app.exec_()) sys.exit(app.exec_())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment