Изменение опций виджета Кнопка
Автор: vare • Ноябрь 1, 2020 • Контрольная работа • 302 Слов (2 Страниц) • 281 Просмотры
Изменение опций виджета Кнопка
from tkinter import *
root = Tk()
def but_onoff(event, button):
if button == "Click Me":
but["text"] = "Clicks 1"
but["width"] = 10
but["height"] = 2
elif button == "Clicks 1":
but["text"] = "Clicks 2"
but["width"] = 22
but["height"] = 5
elif button == "Clicks 2":
but["text"] = "Clicks 3"
but["width"] = 30
but["height"] = 7
elif button == "Clicks 3":
but["text"] = "Clicks 4"
but["width"] = 25
but["height"] = 6
elif button == "Clicks 4":
but["text"] = "Clicks 5"
but["width"] = 20
but["height"] = 5
elif button == "Clicks 5":
but["text"] = "Clicks 6"
but["width"] = 15
but["height"] = 4
elif button == "Clicks 6":
but["text"] = "Clicks 1"
but["width"] = 10
but["height"] = 2
root.title('Мое первое GUI приложение')
root.geometry("600x400+1000+300")
but = Button(root, text="Click Me", width=20, height=5, bg="grey50", fg="blue")
but.pack()
but.bind("<Button-1>", lambda event: but_onoff(event, but["text"]))
root.mainloop()
[pic 1]
[pic 2]
[pic 3]
[pic 4]
[pic 5]
[pic 6]
[pic 7]
[pic 8]
...