繰り返し処理(タイマー)

2020/12/01

Python2.7.8, PySide1.2.2

# -*- coding: utf-8 -*-

import sys
from PySide import QtCore,QtGui

class MainWindow(QtGui.QMainWindow):
    def __init__(self, *argv, **keywords ):
        super(MainWindow,self).__init__(*argv,**keywords)

        self.timer = QtCore.QTimer(self)
        self.timer.setInterval(1000)
        self.timer.timeout.connect(self.loop)
        self.timer.start()

    def loop(self):
        print('yo')

def main():
    app = QtGui.QApplication(sys.argv)
    w = MainWindow()
    w.show()
    sys.exit(app.exec_())

if __name__ == '__main__':
    main()