Created
February 7, 2017 21:18
-
-
Save asyd/13624e0e70429e997ab240b44847a640 to your computer and use it in GitHub Desktop.
Qt4 Timer example
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
#!/usr/bin/env python | |
import sys | |
from PyQt4.QtCore import * | |
from PyQt4.QtGui import * | |
from PyQt4.uic import * | |
import random | |
class App(QMainWindow): | |
def __init__(self): | |
QMainWindow.__init__(self) | |
self.ui = loadUi("example.ui") | |
self.ui.show() | |
self.timer = QTimer() | |
self.timer.setInterval(1000) | |
self.timer.timeout.connect(self.updateBed) | |
self.timer.start() | |
def updateBed(self): | |
self.ui.bedTemperature.setText(str(random.randint(50, 60))) | |
if __name__ == '__main__': | |
app = QApplication(sys.argv) | |
win = App() | |
app.exec_() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment