Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- root = Tk()
- root.geometry("200x200")
- #создаем объект кнопка
- but = Button(root, text = "Печать", width = 20)
- but2 = Button(root, text = "1")
- but3 = Button(root)
- #устанавливаем её свойсвта
- #but3["width"] = "90"
- def print_hello(event):
- print("Hello world")
- but["text"] += "."
- but["fg"], but["bg"] = but["bg"], but["fg"]
- #event listener
- but.bind("<Button-1>", print_hello)
- but2.bind("<Left>", print_hello)
- #событие <---> действие
- #|
- #v
- #место действия (виджет)
- #размещаем кнопку на форме window manager
- but.pack()
- but2.pack()
- but3.pack()
- root.mainloop()
Add Comment
Please, Sign In to add comment