hello,
Using Python 2.7, PyQt4, Qt Designer, and used pyuic4... I think thats it... windows 7?
I have a GUI i created in Qt Designer. It has one button and one LCD number. I was trying to get the button to start and reset a timer, and have the elapsed time displayed as value on the LCD number in hh:mm:ss format.
I have done numberous searches online, and found examples in other languages except for python? I have found examples that print time, but nothing in python which links to the LCD number from Qt Designer? Maybe it cant be done? Ive seen sliders and combo boxes linked to LCD number... but no buttons?
oh i almsot forgot, im also hoping that a window can "pop-up" after 40 minutes and say "Great Job, Nothing can slow you down!"
Here is my code... (I think im looking for the rest of "def doStartReset(self):" function/method)...
I hope i've posted everything you need...
thanks in advance guys! and gals!!! :)
#!/usr/bin/python2.7
import sys
from PyQt4 import QtGui,QtCore
from timer_ui import *
class MyForm(QtGui.QMainWindow):
def __init__(self, parent=None):
#build parent user interface
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
QtCore.QObject.connect(self.ui.btnStartReset, QtCore.SIGNAL('clicked()'), self.doStartReset)
def doStartReset(self):
if __name__ == "__main__":
#This function means this was run directly, not called from another python file.
app = QtGui.QApplication(sys.argv)
myapp = MyForm()
myapp.show()
sys.exit(app.exec_())
here is the gui in ui.py form if you need to peek at it!
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'timer.ui'
from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
_fromUtf8 = lambda s: s
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(340, 205)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.widget = QtGui.QWidget(self.centralwidget)
self.widget.setGeometry(QtCore.QRect(40, 50, 261, 81))
self.widget.setObjectName(_fromUtf8("widget"))
self.gridLayout = QtGui.QGridLayout(self.widget)
self.gridLayout.setMargin(0)
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
self.btnStartReset = QtGui.QPushButton(self.widget)
self.btnStartReset.setObjectName(_fromUtf8("btnStartReset"))
self.gridLayout.addWidget(self.btnStartReset, 0, 0, 1, 1)
self.lcd40MinTimer = QtGui.QLCDNumber(self.widget)
self.lcd40MinTimer.setObjectName(_fromUtf8("lcd40MinTimer"))
self.gridLayout.addWidget(self.lcd40MinTimer, 0, 1, 1, 1)
MainWindow.setCentralWidget(self.centralwidget)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8))
self.btnStartReset.setText(QtGui.QApplication.translate("MainWindow", "Start / Reset", None, QtGui.QApplication.UnicodeUTF8))