Advertisement
fevzi02

3.1

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