Advertisement
here2share

# Tk_sketchpad_min.py

Sep 29th, 2016
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. # Tk_sketchpad_min.py
  2.  
  3. from Tkinter import Tk, Canvas
  4.  
  5. def begin(event):
  6.     global oldx, oldy
  7.     oldx, oldy=event.x, event.y
  8. def draw(event):
  9.     global oldx, oldy, canas
  10.     newx, newy=event.x, event.y
  11.     canvas.create_line (oldx, oldy, newx, newy)
  12.     oldx, oldy=newx, newy
  13. root=Tk()
  14. oldx, oldy=0,0
  15. canvas=Canvas(root, height=2000, width=3000)
  16. canvas.bind("<Button-1>",begin)
  17. canvas.bind("<Button1-Motion>",draw)
  18. canvas.pack()
  19.  
  20. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement