|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- from tkinter import *
- root=Tk()
- root.title("Tkinter : background")
- def gyl(a,b,c):
- def abc():
- if a== "mediumseagreen":
- m.config(background=a)
- elif a=="mediumvioletred" :
- n.config(background=b)
- else:
- o.config(background=c)
- m=Button(root,text="兰州",command=abc).pack()
- n=Button(root,text="广州",command=abc).pack()
- o=Button(root,text="杭州",command=abc).pack()
- gyl("mediumturquoise","mediumvioletred","mediumspringgreen")
- mainloop()
复制代码
一定记得单独写组件定义
- from tkinter import *
- root = Tk()
- root.title("Tkinter: background")
- def gyl(a, b, c):
- def abc():
- if a == "mediumturquoise":
- m.config(bg=a)
- elif a == "mediumvioletred":
- n.config(bg=b)
- else:
- o.config(bg=c)
-
- m = Button(root, text="兰州", command=abc)
- m.pack()
-
- n = Button(root, text="广州", command=abc)
- n.pack()
-
- o = Button(root, text="杭州", command=abc)
- o.pack()
- gyl("mediumturquoise", "mediumvioletred", "mediumspringgreen")
- root.mainloop()
复制代码
|
|