Attachment 'turtled.py'

Download

   1 #!/usr/bin/env python
   2 
   3 from turtle import *
   4 
   5 reset()
   6 
   7 X,Y = 0,0
   8 def Store(x,y):
   9     global X,Y
  10     X,Y=x,y
  11     Goto(X,Y,x,y)
  12 
  13 def Color():
  14     color(raw_input("Enter color name: "))
  15 
  16 def Goto(X,Y,x,y):
  17     up()
  18     goto(x,y)
  19 
  20 def Line(X,Y,x,y):
  21     up()
  22     goto(X,Y)
  23     down()
  24     goto(x,y)
  25     up()
  26 
  27 Todo = Goto
  28 
  29 def Action(x,y):
  30     global Todo
  31     Todo(X,Y,x,y)
  32     Todo = Goto
  33 
  34 def SetLine():
  35     global Todo
  36     Todo = Line
  37 
  38 onscreenclick(Store)
  39 onrelease(Action)
  40 onkey(bye,"q")
  41 onkey(Color," ")
  42 onkey(SetLine,"l")
  43 
  44 listen()
  45 mainloop()

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.

You are not allowed to attach a file to this page.