snowden_web

Win_app 1

Nov 25th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. from tkinter import *
  2.  
  3. root = Tk()
  4. root.geometry("200x200")
  5.  
  6. #создаем объект кнопка
  7. but = Button(root, text = "Печать", width = 20)
  8. but2 = Button(root, text = "1")
  9. but3 = Button(root)
  10.  
  11. #устанавливаем её свойсвта
  12. #but3["width"] = "90"
  13.  
  14.  
  15. def print_hello(event):
  16.     print("Hello world")
  17.     but["text"] += "."
  18.     but["fg"], but["bg"] = but["bg"],  but["fg"]
  19.  
  20.  
  21.  
  22. #event listener
  23. but.bind("<Button-1>", print_hello)
  24. but2.bind("<Left>", print_hello)
  25.  
  26. #событие <---> действие
  27.            #|
  28.            #v
  29.   #место действия (виджет)
  30.  
  31. #размещаем кнопку на форме window manager
  32. but.pack()
  33. but2.pack()
  34. but3.pack()
  35.  
  36. root.mainloop()
Add Comment
Please, Sign In to add comment