|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- from tkinter import *
- import random
- root=Tk()
- root.geometry("444x555")
- a=f"#{random.randint(0x456ABC,0xABC456):06x}"
- root.config(background=a)
- p=[{"name":"A","hue":"hotpink"},
- {"name":"B","hue":"mediumorchid"},
- {"name":"C","hue":"lightcoral"},
- {"name":"D","hue":"chocolate"},
- {"name":"E","hue":"crimson"}]
- r=True
- def n():
- global r,m
- if r :
- m[4].config(background="#A0B0C0")
- f=False
- else :
- m[4].config(background="#0A0B0C")
- f=True
- m[4].after(2026,n)
- m=list()
- for i in range(len(p)) :
- q=Button(root,text=p[i]["name"],foreground=p[i]["hue"],pady=23,width=23)
- q.pack(expand=True)
- m.append(q)
- m[4].config(command=n)
- mainloop()
复制代码
按钮【E】的底色,如何动起来?
- from tkinter import *
- import random
- root=Tk()
- root.geometry("444x555")
- a=f"#{random.randint(0x456ABC,0xABC456):06x}"
- root.config(background=a)
- p=[{"name":"A","hue":"hotpink"},
- {"name":"B","hue":"mediumorchid"},
- {"name":"C","hue":"lightcoral"},
- {"name":"D","hue":"chocolate"},
- {"name":"E","hue":"crimson"}]
- r=True
- def n():
- global r
- if r:
- m[4].config(background="#A0B0C0")
- r=False
- else:
- m[4].config(background="#0A0B0C")
- r=True
- m[4].after(200,n)
- m=[]
- for i in p:
- q=Button(root,text=i["name"],foreground=i["hue"],pady=23,width=23)
- q.pack(expand=True)
- m.append(q)
- n()
- mainloop()
复制代码
|
|