簡単ですがTkinter
だと以下のコードで実現できます。
Python
1import tkinter as tk
2
3# 点滅するボール
4class Ball(object):
5 root = None
6 canvas = None
7
8 # pos=位置, fill=色, dt=点滅間隔[msec]
9 def __init__(self,id,pos,fill,dt):
10 self.id= str(id)
11 self.state = 'normal'
12 self.dt = dt
13 Ball.canvas.create_oval( pos,pos,pos+50,pos+50, tags=self.id, fill=fill)
14
15 Ball.root.after(self.dt, self.blink)
16
17 def blink(self):
18 if self.state == 'normal':
19 self.state = 'hidden'
20 else:
21 self.state = 'normal'
22 self.canvas.itemconfigure(self.id, state=self.state)
23 self.root.after(self.dt, self.blink)
24
25
26class MyFrame(tk.Frame):
27
28 def __init__(self,root):
29 tk.Frame.__init__(self,root)
30 self.root = root
31 self.pack()
32
33 self.canvas = tk.Canvas(self, width=200, height=200, bg="white")
34 self.canvas.pack()
35
36 Ball.root = root
37 Ball.canvas = self.canvas
38 self.b1 = Ball(1, 50, 'red', 100)
39 self.b2 = Ball(2, 100, 'blue', 500)
40
41
42if __name__ == '__main__':
43 root = tk.Tk()
44 root.title('blink')
45 frame = MyFrame(root)
46 frame.mainloop()