gorskaja2019

example 2

Apr 3rd, 2019
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. from tkinter import *
  2.  
  3. root = Tk()
  4.  
  5. def on_click(event):
  6. global cnt
  7. cnt += 1
  8.  
  9. print('Hello!')
  10. if cnt == 2:
  11. t = event.widget
  12. t.unbind('<Button-1>')
  13.  
  14. cnt = 0
  15.  
  16. button1 = Button(width = 3, height = 3, bg = 'skyblue')
  17. button1.grid(row = 0, column = 0)
  18. button1.bind('<Button-1>', on_click)
  19.  
  20. button2 = Button(width = 3, height = 3, bg = 'orange')
  21. button2.grid(row = 0, column = 1)
  22. button2.bind('<Button-1>', on_click)
  23.  
  24. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment