Created
October 13, 2012 08:40
-
-
Save lacolaco/3883846 to your computer and use it in GitHub Desktop.
Timer application by Python3.2.3 with PyQt4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| # Form implementation generated from reading ui file 'timer.ui' | |
| # | |
| # Created: Sat Oct 13 17:10:09 2012 | |
| # by: PyQt4 UI code generator 4.9.4 | |
| # | |
| # WARNING! All changes made in this file will be lost! | |
| from PyQt4 import QtCore, QtGui | |
| try: | |
| _fromUtf8 = QtCore.QString.fromUtf8 | |
| except AttributeError: | |
| _fromUtf8 = lambda s: s | |
| class Ui_MainWindow(object): | |
| def __init__(self): | |
| self.count = 0 | |
| self.lcdNumber = None | |
| self.timer = None | |
| def update_display(self): | |
| self.lcdNumber.display("%.1f" % (self.count / 100)) | |
| self.lcdNumber.update() | |
| def do_countdown(self): | |
| self.count -= 1 | |
| self.update_display() | |
| if self.count <= 0: | |
| self.stop_countdown() | |
| def start_countdown(self): | |
| if self.count > 0: | |
| self.timer.start() | |
| def stop_countdown(self): | |
| self.timer.stop() | |
| def reset_countdown(self): | |
| self.timer.stop() | |
| self.count = 18000 | |
| self.update_display() | |
| def setupUi(self, MainWindow): | |
| self.timer = QtCore.QTimer() | |
| self.timer.setInterval(10) | |
| self.timer.timeout.connect(self.do_countdown) | |
| MainWindow.setObjectName(_fromUtf8("MainWindow")) | |
| MainWindow.resize(800, 600) | |
| self.centralwidget = QtGui.QWidget(MainWindow) | |
| self.centralwidget.setObjectName(_fromUtf8("centralwidget")) | |
| self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget) | |
| self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) | |
| self.lcdNumber = QtGui.QLCDNumber(self.centralwidget) | |
| self.lcdNumber.setObjectName(_fromUtf8("lcdNumber")) | |
| self.verticalLayout.addWidget(self.lcdNumber) | |
| self.gridLayout = QtGui.QGridLayout() | |
| self.gridLayout.setObjectName(_fromUtf8("gridLayout")) | |
| self.resetButton = QtGui.QPushButton(self.centralwidget) | |
| self.resetButton.setObjectName(_fromUtf8("resetButton")) | |
| self.gridLayout.addWidget(self.resetButton, 1, 0, 1, 1) | |
| self.startButton = QtGui.QPushButton(self.centralwidget) | |
| self.startButton.setObjectName(_fromUtf8("startButton")) | |
| self.gridLayout.addWidget(self.startButton, 0, 0, 1, 1) | |
| self.stopButton = QtGui.QPushButton(self.centralwidget) | |
| self.stopButton.setObjectName(_fromUtf8("stopButton")) | |
| self.gridLayout.addWidget(self.stopButton, 0, 1, 1, 1) | |
| self.quitButton = QtGui.QPushButton(self.centralwidget) | |
| self.quitButton.setObjectName(_fromUtf8("quitButton")) | |
| self.gridLayout.addWidget(self.quitButton, 1, 1, 1, 1) | |
| self.verticalLayout.addLayout(self.gridLayout) | |
| MainWindow.setCentralWidget(self.centralwidget) | |
| self.retranslateUi(MainWindow) | |
| QtCore.QObject.connect(self.startButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.start_countdown) | |
| QtCore.QObject.connect(self.stopButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.stop_countdown) | |
| QtCore.QObject.connect(self.resetButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.reset_countdown) | |
| QtCore.QObject.connect(self.quitButton, QtCore.SIGNAL(_fromUtf8("clicked()")), MainWindow.close) | |
| QtCore.QMetaObject.connectSlotsByName(MainWindow) | |
| self.reset_countdown() | |
| def retranslateUi(self, MainWindow): | |
| MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "ラーメンタイマー", None, QtGui.QApplication.UnicodeUTF8)) | |
| self.resetButton.setText(QtGui.QApplication.translate("MainWindow", "RESET", None, QtGui.QApplication.UnicodeUTF8)) | |
| self.startButton.setText(QtGui.QApplication.translate("MainWindow", "START", None, QtGui.QApplication.UnicodeUTF8)) | |
| self.stopButton.setText(QtGui.QApplication.translate("MainWindow", "STOP", None, QtGui.QApplication.UnicodeUTF8)) | |
| self.quitButton.setText(QtGui.QApplication.translate("MainWindow", "QUIT", None, QtGui.QApplication.UnicodeUTF8)) | |
| if __name__ == "__main__": | |
| import sys | |
| app = QtGui.QApplication(sys.argv) | |
| MainWindow = QtGui.QMainWindow() | |
| ui = Ui_MainWindow() | |
| ui.setupUi(MainWindow) | |
| MainWindow.show() | |
| app.exec_() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment