Advertisement
here2share

# Tk_click_me_btn.py

Sep 27th, 2016
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. # Tk_click_me_btn.py
  2.  
  3. from Tkinter import *
  4. from random import *
  5.  
  6. def do_event(event):
  7.     print
  8.     print "M: {},{}".format(event.x,event.y)
  9.  
  10. def jump(event):
  11.     zx,zy=randint(5,160),randint(5,160)
  12.     print "B: {},{}".format(zx,zy)
  13.     meBtn.place(x=zx,y=zy)
  14.  
  15. def caught():
  16.     print "You Caught Me !!!"
  17.  
  18.  
  19. root = Tk()
  20.  
  21. frame = Frame(root)
  22. root.geometry("200x200")
  23. root.title('CMIYC!')
  24. root.bind("<Button-1>",do_event)
  25. lbl=Label(root, text='Click "ME" If You Can!')
  26. lbl.pack()
  27. frame.pack()
  28.  
  29. meBtn = Button(root,text='"ME"',command=caught)
  30. meBtn.bind("<Enter>",jump)
  31. meBtn.pack()
  32.  
  33. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement