Skip to content

Instantly share code, notes, and snippets.

@asyd
Created February 7, 2017 21:18
Show Gist options
  • Save asyd/13624e0e70429e997ab240b44847a640 to your computer and use it in GitHub Desktop.
Save asyd/13624e0e70429e997ab240b44847a640 to your computer and use it in GitHub Desktop.
Qt4 Timer example
#!/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