python 击鼓传花
root=tk.Tk()
root.geometry("300x300")
s=0
cs=1
flag=True
def fun():
global s
if flag:
x.set(s)
s+=1
root.after(500,fun)
if s==5:
s=0
def ks(event):
global flag,cs
flag=True
if cs==1:
cs+=1
fun()
def zt(event):
global flag,cs
cs=1
flag=False
x=tk.IntVar()
r1=tk.Radiobutton(root,text="金",variable=x,value=0)
r1.place(relx=0.4,rely=0.1)
r2=tk.Radiobutton(root,text="木",variable=x,value=1)
r2.place(relx=0.5,rely=0.2)
r3=tk.Radiobutton(root,text="水",variable=x,value=2)
r3.place(relx=0.45,rely=0.3)
r4=tk.Radiobutton(root,text="火",variable=x,value=3)
r4.place(relx=0.3,rely=0.3)
r5=tk.Radiobutton(root,text="土",variable=x,value=4)
r5.place(relx=0.25,rely=0.2)
x.set(0)
b1=tk.Button(root,text="开始")
b1.pack(side="bottom")
b1.bind("<ButtonPress>",ks)
b2=tk.Button(root,text="暂停")
b2.pack(side="bottom")
b2.bind("<ButtonPress>",zt)
b3=tk.Button(root,text="退出",command=root.destroy)
b3.pack(side="bottom")
root.mainloop()