help:problem using the RawPen class/turtle module.

alex ale_xp at yahoo.com
Sat Apr 6 06:03:14 EST 2002


Hi all, I'm a Python beginner, and I'm trying to use
the module "turtle" to do some turtle graphics.
But I have a problem when I try to use the turtle
class RawPen in order to use it with a Canvas. 
In particular when I try to run the following code: ...

...
root = Tkinter.Tk()
c       =   Tkinter.Canvas(root,heigh=200,width=300)
c.pack()
mypen   =   turtle.RawPen(c)
... 

I have the following error message:   

  File "l-turtle2.py", line 56, in ?
    mypen=turtle.RawPen(c)
  File "/usr/local/lib/python2.2/lib-tk/turtle.py", line 16, in __init__
    self.reset()
  File "/usr/local/lib/python2.2/lib-tk/turtle.py", line 42, in reset
    self.clear()
  File "/usr/local/lib/python2.2/lib-tk/turtle.py", line 53, in clear
    self._draw_turtle()
  File "/usr/local/lib/python2.2/lib-tk/turtle.py", line 262, in _draw_turtle
    self._arrow = _canvas.create_line(x-dx,y+dy,x,y,
AttributeError: 'NoneType' object has no attribute 'create_line' 

The Python Library Reference documentation section 16.4 (Turtle)
shows that the RawPen class has to be called with a canvas as argument.
I don't know if there is other documentation on this topic.

thank you in advance.

Alex



More information about the Python-list mailing list