Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. Листинг программы:
  2. from tkinter import *
  3. root = Tk()
  4. root.geometry("500x220")
  5. # Закрытие окна
  6. def close():
  7. root.destroy()
  8. # Функция для Scale
  9. def forget_s(event):
  10. global button
  11. if button == 1:
  12. b1.place(x=50, y=70)
  13. elif button == 2:
  14. b2.place(x=150, y=70)
  15. elif button == 3:
  16. b3.place(x=250, y=70)
  17. elif button == 4:
  18. b4.place(x=350, y=70)
  19. if s.get() == 1:
  20. b1.place_forget()
  21. button = 1
  22. elif s.get() == 2:
  23. b2.place_forget()
  24. button = 2
  25. elif s.get() == 3:
  26. b3.place_forget()
  27. button = 3
  28. elif s.get() == 4:
  29. b4.place_forget()
  30. button = 4
  31. l.config(text="Кнопка скрыта:" + str(button))
  32.  
  33. # Функция для Button
  34. button = 4
  35. def forget_b(number):
  36. global button
  37. if button == 1:
  38. b1.place(x=50, y=70)
  39. elif button == 2:
  40. b2.place(x=150, y=70)
  41. elif button == 3:
  42. b3.place(x=250, y=70)
  43. elif button == 4:
  44. b4.place(x=350, y=70)
  45. if number == 1:
  46. b1.place_forget()
  47. s.set(1)
  48. button = 1
  49. elif number == 2:
  50. b2.place_forget()
  51. s.set(2)
  52. button = 2
  53. elif number == 3:
  54. b3.place_forget()
  55. s.set(3)
  56. button = 3
  57. elif number == 4:
  58. b4.place_forget()
  59. s.set(4)
  60. button = 4
  61. l.config(text="Кнопка скрыта:" + str(button))
  62.  
  63. # Метка
  64. l = Label(text="Кнопка скрыта:" + str(button))
  65. l.place(x=200, y=20)
  66. # Кнопки
  67. b1 = Button(text="1", width=7, command=lambda: forget_b(1))
  68. b1.place(x=50, y=70)
  69. b2 = Button(text="2", width=7, command=lambda: forget_b(2))
  70. b2.place(x=150, y=70)
  71. b3 = Button(text="3", width=7, command=lambda: forget_b(3))
  72. b3.place(x=250, y=70)
  73. b4 = Button(text="4", width=7, command=lambda: forget_b(4))
  74. b4.place_forget()
  75. bclose = Button(text="Закрыть", command=close)
  76. bclose.place(x=230, y=180)
  77. # СкроллБар
  78. s = Scale(orient=HORIZONTAL, from_=1, to=4, tickinterval=1, length=300, command=forget_s)
  79. s.set(4)
  80. s.place(x=100, y=120)
  81.  
  82. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement