並行処理

2022/11/18

Python2.7.8

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

import Tkinter

class Window(Tkinter.Tk):
    def __init__(self):
        Tkinter.Tk.__init__(self)
        self.n1 = 0
        self.n2 = 0

    def loop1(self):
        print('loop1 %d' % self.n1)
        self.n1 += 1
        self.update_idletasks()
        self.after(0,self.loop1)

    def loop2(self):
        print('loop2 %d' % self.n2)
        self.n2 += 1
        self.update_idletasks()
        self.after(0,self.loop2)

def main():
    w = Window()
    w.after(0,w.loop1)
    w.after(0,w.loop2)
    w.mainloop()

if __name__ == '__main__':
    main()