1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| import Tkinter
from Tkinter import *
from threading import Thread
import threading
import time
done = threading.Event()
def touch(event):
fen.destroy()
def go():
global a,t,b,init
can.delete(ALL)
if init==1:
a=b
init=0
if t<=len(a)-1:
can.create_text(100,100, text=a[t], font="Cambria 18 bold", fill="gold")
t+=1
fen.after(1000,go)
else:
a=b
t=0
go()
def var():
global b,init
c=1
init=1
while not done.is_set():
c+=1
b=range(c)
time.sleep(5)
a=[]
b=[]
init=0
t=0
fen=Tk()
fen.bind('<Escape>', touch)
can=Canvas(fen,width=w-w/4,height=h-h/10,highlightthickness=0,bg='white')
can.grid(row=0)
th=Thread(target=var)
th.start()
go()
fen.mainloop()
done.set()
th.join() |
Partager