Advertisement
here2share

# Tk_spacebar_event.py

Sep 6th, 2016
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. # Tk_spacebar_event.py
  2.  
  3. from Tkinter import *
  4. from random import *
  5.  
  6. root=Tk()
  7. canvas=Canvas(root,width=400,height=300,bg='white')
  8. def draw(event=None):
  9.     canvas.delete(ALL)# clear canvas first
  10.     canvas.create_oval(randint(1,180),randint(1,120),randint(210,399),randint(180,299),fill='red')
  11. draw()
  12. canvas.pack()
  13.  
  14. root.bind("<space>", draw)
  15. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement