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 @@
<property name="correctionMode">
<enum>QAbstractSpinBox::CorrectToNearestValue</enum>
</property>
<property name="minimum">
<number>-9900</number>
</property>
<property name="maximum">
<number>9900</number>
</property>
......@@ -79,6 +82,9 @@
<property name="correctionMode">
<enum>QAbstractSpinBox::CorrectToNearestValue</enum>
</property>
<property name="minimum">
<number>-9900</number>
</property>
<property name="maximum">
<number>9900</number>
</property>
......@@ -95,6 +101,9 @@
<property name="correctionMode">
<enum>QAbstractSpinBox::CorrectToNearestValue</enum>
</property>
<property name="minimum">
<number>-9900</number>
</property>
<property name="maximum">
<number>9900</number>
</property>
......@@ -111,6 +120,9 @@
<property name="correctionMode">
<enum>QAbstractSpinBox::CorrectToNearestValue</enum>
</property>
<property name="minimum">
<number>-9900</number>
</property>
<property name="maximum">
<number>9900</number>
</property>
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<class>Question</class>
<widget class="QDialog" name="Question">
<property name="windowModality">
<enum>Qt::NonModal</enum>
</property>
......@@ -14,7 +14,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>Question</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
......@@ -31,6 +31,19 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</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>
</widget>
<resources/>
......
......@@ -24,6 +24,7 @@ IP = "127.0.0.1"
PLAYERS_MAX = 4
CATEGORIES_MAX = 5
QUESTION_LENGTH_MAX = 1024 * 1024
TIMEOUT = 60
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~ CLASS DEFINITION ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......@@ -341,8 +342,20 @@ class QuestionGUI(QDialog):
QDialog.__init__(self)
self.UI_Question = loadUi("GUIs/question.ui", self)
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()
def timeHandler(self):
if self.time > 0:
self.time -= 1
else:
self.time = 0
self.UI_Question.TimeLCD.display(self.time)
class MainGUI(QMainWindow):
def __init__(self):
......
import sys
from PyQt4 import QtGui, QtCore
class Main(QtGui.QMainWindow):
def __init__(self):
......@@ -17,18 +18,18 @@ class Main(QtGui.QMainWindow):
self.time = QtGui.QTimeEdit(self)
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.stop = QtGui.QPushButton("Stop",self)
self.stop = QtGui.QPushButton("Stop", self)
self.stop.clicked.connect(lambda: self.timer.stop())
grid = QtGui.QGridLayout(self)
grid.addWidget(self.lcd,3,0)
grid.addWidget(self.time,0,0)
grid.addWidget(self.set,1,0)
grid.addWidget(self.stop,2,0)
grid.addWidget(self.lcd, 3, 0)
grid.addWidget(self.time, 0, 0)
grid.addWidget(self.set, 1, 0)
grid.addWidget(self.stop, 2, 0)
centralwidget = QtGui.QWidget()
......@@ -38,10 +39,10 @@ class Main(QtGui.QMainWindow):
#---------Window settings --------------------------------
self.setGeometry(300,300,280,170)
self.setGeometry(300, 300, 280, 170)
def Set(self):
global t,h,m,s
global t, h, m, s
t = self.time.time()
self.lcd.display(t.toString())
......@@ -53,10 +54,10 @@ class Main(QtGui.QMainWindow):
s = t.second()
def Time(self):
global t,h,m,s
global t, h, m, s
if s > 0:
s -=1
s -= 1
else:
if m > 0:
m -= 1
......@@ -67,16 +68,17 @@ class Main(QtGui.QMainWindow):
s = 59
else:
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.display(time)
def main():
app = QtGui.QApplication(sys.argv)
main= Main()
main = Main()
main.show()
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