タイマー

2015/2/15

Python2.7.6, pyQt4.11

import sys,os
from PyQt4 import QtCore, QtGui

class Main:
    def __init__(self):

        self.window = QtGui.QWidget()
        self.window.resize(200,100)

        self.label = QtGui.QLabel("test",self.window)
        self.label.move(20,20)

        self.timer = QtCore.QTimer(self.window)
        self.timer.setInterval(100)
        self.timer.timeout.connect(self.reload)
        self.timer.start()

        self.window.show()

    n = 0.0
    def reload(self):
        self.label.setText(str(self.n))
        self.n += 0.1

if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    main = Main()
    sys.exit(app.exec_())


QTimer Class Reference
http://pyqt.sourceforge.net/Docs/PyQt4/qtimer.html