This paper is finally updated at 1163 Days ago, , The information may have developed or changed .
from tkinter import *
import threading
import time
root = Tk()
root.title(' Large turntable ')
root.minsize(300,300)
btn1=Button(root,text=' Cherry ',bg='red')
btn1.place(x=20,y=20,width=50,height=50)
btn2 = Button(root, text=' Banana ', bg='white')
btn2.place(x=90, y=20, width=50, height=50)
btn3 = Button(root, text=' Apple ', bg='white')
btn3.place(x=160, y=20, width=50, height=50)
btn4 = Button(root, text=' watermelon ', bg='white')
btn4.place(x=230, y=20, width=50, height=50)
btn5 = Button(root, text=' Yali Pear ', bg='white')
btn5.place(x=230, y=90, width=50, height=50)
btn6 = Button(root, text=' durian ', bg='white')
btn6.place(x=230, y=160, width=50, height=50)
btn7 = Button(root, text=' grapefruit ', bg='white')
btn7.place(x=230, y=230, width=50, height=50)
btn8 =Button(root, text=' grapes ', bg='white')
btn8.place(x=160, y=230, width=50, height=50)
btn9 = Button(root, text=' strawberry ', bg='white')
btn9.place(x=90, y=230, width=50, height=50)
btn10 = Button(root, text=' Mango. ', bg='white')
btn10.place(x=20, y=230, width=50, height=50)
btn11 = Button(root, text=' litchi ', bg='white')
btn11.place(x=20, y=160, width=50, height=50)
btn12 = Button(root, text=' Sugar cane ', bg='white')
btn12.place(x=20, y=90, width=50, height=50)
fruitlist=[btn1,btn2,btn3,btn4,btn5,btn6,btn7,btn8,btn9,btn10,btn11,btn12,]
i=0
stopid=0
flag=False
def round():
global i
global flag
global stopid
print(' Get into round')
for item in fruitlist:
item['bg']='white'
while True:
fruitlist[i]['bg']='red'
time.sleep(0.2)
fruitlist[i]['bg']='white'
print(i)
if i>=11:
i=0
else:
i+=1
if not flag:
stopid=i
fruitlist[i]['bg']='red'
break
def action():
global flag
global i
print(' Get into action')
if not flag:
flag=True
i=stopid
t=threading.Thread(target=round)
t.start()
def stop():
print(' Get into stop')
global flag
flag=False
btn_start=Button(root,text=' Start ',command=lambda : action())
btn_start.place(x=90,y=125,width=50,height=50)
btn_stop=Button(root,text=' Pause ',command=lambda : stop())
btn_stop.place(x=160,y=125,width=50,height=50)
root.mainloop()
Post Views: 435