|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- from tkinter import *
- import random
- root = Tk()
- l=[{"district":"南昌市","hue":"khaki"},{"district":"赣州市","hue":"burlywood"},
- {"district":"宜春市","hue":"lightgray"},{"district":"吉安市","hue":"cyan"},
- {"district":"上饶市","hue":"dodgerblue"},{"district":"抚州市","hue":"salmon"},
- {"district":"九江市","hue":"brown"},{"district":"景德镇市","hue":"deeppink"},
- {"district":"萍乡市","hue":"cornflowerblue"},{"district":"新余市","hue":"lime"},
- {"district":"鹰潭市","hue":"peru"}]
- random.shuffle(l)
- u=list()
- for i in range(len(l)):
- h=Button(root,text=l[i]["district"],background=l[i]["hue"])
- h.pack(expand=True)
- u.append(h)
- def p():
- u[0].after(2000,u[0].config(background=u[1]["b"]))
- u[2].after(2000,u[2].config(background=u[3]["b"]))
- u[4].after(2000,u[4].config(background=u[5]["b"]))
- u[6].after(2000,u[6].config(background=u[7]["b"]))
- u[8].after(2000,u[8].config(background=u[9]["b"]))
- root.after(5000,p)
- mainloop()
复制代码
|
|