Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Листинг программы:
- from tkinter import *
- root = Tk()
- root.geometry("500x220")
- # Закрытие окна
- def close():
- root.destroy()
- # Функция для Scale
- def forget_s(event):
- global button
- if button == 1:
- b1.place(x=50, y=70)
- elif button == 2:
- b2.place(x=150, y=70)
- elif button == 3:
- b3.place(x=250, y=70)
- elif button == 4:
- b4.place(x=350, y=70)
- if s.get() == 1:
- b1.place_forget()
- button = 1
- elif s.get() == 2:
- b2.place_forget()
- button = 2
- elif s.get() == 3:
- b3.place_forget()
- button = 3
- elif s.get() == 4:
- b4.place_forget()
- button = 4
- l.config(text="Кнопка скрыта:" + str(button))
- # Функция для Button
- button = 4
- def forget_b(number):
- global button
- if button == 1:
- b1.place(x=50, y=70)
- elif button == 2:
- b2.place(x=150, y=70)
- elif button == 3:
- b3.place(x=250, y=70)
- elif button == 4:
- b4.place(x=350, y=70)
- if number == 1:
- b1.place_forget()
- s.set(1)
- button = 1
- elif number == 2:
- b2.place_forget()
- s.set(2)
- button = 2
- elif number == 3:
- b3.place_forget()
- s.set(3)
- button = 3
- elif number == 4:
- b4.place_forget()
- s.set(4)
- button = 4
- l.config(text="Кнопка скрыта:" + str(button))
- # Метка
- l = Label(text="Кнопка скрыта:" + str(button))
- l.place(x=200, y=20)
- # Кнопки
- b1 = Button(text="1", width=7, command=lambda: forget_b(1))
- b1.place(x=50, y=70)
- b2 = Button(text="2", width=7, command=lambda: forget_b(2))
- b2.place(x=150, y=70)
- b3 = Button(text="3", width=7, command=lambda: forget_b(3))
- b3.place(x=250, y=70)
- b4 = Button(text="4", width=7, command=lambda: forget_b(4))
- b4.place_forget()
- bclose = Button(text="Закрыть", command=close)
- bclose.place(x=230, y=180)
- # СкроллБар
- s = Scale(orient=HORIZONTAL, from_=1, to=4, tickinterval=1, length=300, command=forget_s)
- s.set(4)
- s.place(x=100, y=120)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement