Advertisement
fevzi02

3.2

Dec 17th, 2021
701
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. l1 = Label(u2_frame, text="", width=30, height=0, font=("Arial", 16))
  17. l2 = Label(u2_frame, text="", bg='#fff', width=30, height=0,font=("Arial", 12))
  18. b1 = Button(u_frame,  width=5, height=2, bg='#ff0000',command=lambda: bu("#ff0000","красный"))
  19. b2 = Button(u_frame,  width=5, height=2, bg='#ff7d00',command=lambda: bu("#ff7d00","оранжевый"))
  20. b3 = Button(u_frame,  width=5, height=2, bg='#ffff00',command=lambda: bu("#ffff00","желтый"))
  21. b4 = Button(u_frame,  width=5, height=2, bg='#00ff00',command=lambda: bu("#00ff00","зеленый"))
  22. b5 = Button(u_frame,  width=5, height=2, bg='#007dff',command=lambda: bu("#007dff","голубой"))
  23. b6 = Button(u_frame,  width=5, height=2, bg='#0000ff',command=lambda: bu("#0000ff","синий"))
  24. b7 = Button(u_frame,  width=5, height=2, bg='#7d00ff',command=lambda: bu("#7d00ff","фиолетовый"))
  25.  
  26. u2_frame.pack()
  27. u_frame.pack()
  28. b7.pack(pady = 1, padx = 1, side=RIGHT)
  29. b6.pack(pady = 1, padx = 1, side=RIGHT)
  30. b5.pack(pady = 1, padx = 1, side=RIGHT)
  31. b4.pack(pady = 1, padx = 1, side=RIGHT)
  32. b3.pack(pady = 1, padx = 1, side=RIGHT)
  33. b2.pack(pady = 1, padx = 1, side=RIGHT)
  34. b1.pack(pady = 1, padx = 1, side=RIGHT)
  35. l2.pack(pady = 10, padx = 1, side=BOTTOM)
  36. l1.pack(pady = 10, padx = 1, side=BOTTOM)
  37.  
  38.  
  39. root.mainloop()
  40.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement