Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- def bu(n,s):
- global l1
- global l2
- l1.destroy()
- l2.destroy()
- l1 = Label(u2_frame, text=s,width=30, height=0,font=("Arial", 16))
- l2 = Label(u2_frame, text=n, bg='#fff',width=30, height=0,font=("Arial", 12))
- l1.pack(pady = 10)
- l2.pack(pady = 10, padx = 3)
- root = Tk()
- u_frame = Frame(root)
- u2_frame = Frame(root)
- l1 = Label(u2_frame, text="", width=30, height=0, font=("Arial", 16))
- l2 = Label(u2_frame, text="", bg='#fff', width=30, height=0,font=("Arial", 12))
- list_name = [Button(u_frame, width=5, height=2, bg='#ff0000',command=lambda: bu("#ff0000","красный",)),
- Button(u_frame, width=5, height=2, bg='#ff7d00',command=lambda: bu("#ff7d00","оранжевый")),
- Button(u_frame, width=5, height=2, bg='#ffff00',command=lambda: bu("#ffff00","желтый")),
- Button(u_frame, width=5, height=2, bg='#00ff00',command=lambda: bu("#00ff00","зеленый")),
- Button(u_frame, width=5, height=2, bg='#007dff',command=lambda: bu("#007dff","голубой")),
- Button(u_frame, width=5, height=2, bg='#0000ff',command=lambda: bu("#0000ff","синий")),
- Button(u_frame, width=5, height=2, bg='#7d00ff',command=lambda: bu("#7d00ff","фиолетовый"))]
- #==============
- u2_frame.pack()
- u_frame.pack()
- for i in reversed(list_name):
- i.pack(pady = 1, padx = 1, side=RIGHT)
- l2.pack(pady = 10, padx = 1, side=BOTTOM)
- l1.pack(pady = 10, padx = 1, side=BOTTOM)
- #==============
- root.mainloop()
Add Comment
Please, Sign In to add comment