I've searched internet for days but can figure out how to put this code to work. It's a very simple gui (made on Qt Designer) with a lcd and a button. I want it to on the press of the button to start the countdown from 180 seconds back. In the first moment i was able to make to button decrease in one the value but after trying so many different things nothing is working. Can someone help me please? Probably is something very simple. Thank you.
# -*- coding: utf-8 -*-
import sys
import time
from PyQt4 import QtCore, QtGui
from relogio import Ui_relogiocc
class StartQT4(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_relogiocc()
self.ui.setupUi(self)
self.timer = QtCore.QTimer()
text = "%d:%02d" % (180/60,180 % 60)
self.ui.QLCDNumber.display(text)
self.timer.start(1000)
self.ui.iniciar.clicked.connect(self.updateTimerDisplay)
def updateTimerDisplay(self):
self.inicio = 180
while self.inicio != 0:
text = "%d:%02d" % (self.inicio/60,self.inicio % 60)
self.ui.QLCDNumber.display(text)
self.inicio - 1
else:
self.timer.stop()
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
myapp = StartQT4()
myapp.show()
sys.exit(app.exec_())