fevzi02

3.2.New

Dec 17th, 2021 (edited)
247
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from tkinter import *
  2.  
  3. def bu(n,s):
  4.     global l1
  5.     global l2
  6.     l1.destroy()
  7.     l2.destroy()
  8.     l1 = Label(u2_frame, text=s,width=30, height=0,font=("Arial", 16))
  9.     l2 = Label(u2_frame, text=n, bg='#fff',width=30, height=0,font=("Arial", 12))
  10.     l1.pack(pady = 10)
  11.     l2.pack(pady = 10, padx = 3)
  12.  
  13. root = Tk()
  14. u_frame = Frame(root)
  15. u2_frame = Frame(root)
  16.  
  17. l1 = Label(u2_frame, text="", width=30, height=0, font=("Arial", 16))
  18. l2 = Label(u2_frame, text="", bg='#fff', width=30, height=0,font=("Arial", 12))
  19. list_name = [Button(u_frame,  width=5, height=2, bg='#ff0000',command=lambda: bu("#ff0000","красный",)),
  20.             Button(u_frame,  width=5, height=2, bg='#ff7d00',command=lambda: bu("#ff7d00","оранжевый")),
  21.             Button(u_frame,  width=5, height=2, bg='#ffff00',command=lambda: bu("#ffff00","желтый")),
  22.             Button(u_frame,  width=5, height=2, bg='#00ff00',command=lambda: bu("#00ff00","зеленый")),
  23.             Button(u_frame,  width=5, height=2, bg='#007dff',command=lambda: bu("#007dff","голубой")),
  24.             Button(u_frame,  width=5, height=2, bg='#0000ff',command=lambda: bu("#0000ff","синий")),
  25.             Button(u_frame,  width=5, height=2, bg='#7d00ff',command=lambda: bu("#7d00ff","фиолетовый"))]
  26.            
  27. #==============
  28. u2_frame.pack()
  29. u_frame.pack()
  30.  
  31. for i in reversed(list_name):
  32.     i.pack(pady = 1, padx = 1, side=RIGHT)
  33.    
  34. l2.pack(pady = 10, padx = 1, side=BOTTOM)
  35. l1.pack(pady = 10, padx = 1, side=BOTTOM)
  36.  
  37. #==============
  38. root.mainloop()
  39.  
RAW Paste Data Copied