help:problem using the RawPen class/turtle module.
alex
ale_xp at yahoo.com
Sun Apr 7 05:14:06 EDT 2002
missive at frontiernet.net (Lee Harr) wrote in message news:<slrnaauvbv.3v.missive at whave.frontiernet.net>...
> On 6 Apr 2002 03:03:14 -0800, alex <ale_xp at yahoo.com> wrote:
> > 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)
> ^^^^^
> just a transcription typo, right?
yes a bad copy&paste it was 'height' sorry.
>
> > c.pack()
> > mypen = turtle.RawPen(c)
> > ...
> >
>
> I tried this at the interactive python prompt:
>
> import turtle
> import Tk
> root=Tkinter.Tk()
> c=Tkinter.Canvas(root)
> c.pack(expand=1)
> mypen=turtle.RawPen(c)
>
>
> and got no errors.
>
> This was with python2.1 configured with Tkinter
>
> So it may be a configuration (rather than a
> usage or syntax) problem.
Hi,
thank you for your reply,
I tryied to type your code on my python command line
and unfortunatly I have the same message.
So well yes I think you are right, something's wrong
in my configuration.
It seems that it comes from the turtle.py module, I'll
try to have a look at it(even if I'm not an expert of
python modules),
it seems strange to me that it doesn't work because
it is in the standard distribution and of course I
haven't changed it.
I made a copy & paste of my little test.
Python 2.2 (#1, Mar 9 2002, 18:21:48)
[GCC 2.95.2 19991024 (release)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import turtle
>>> import Tkinter
>>> root=Tkinter.Tk()
>>> c=Tkinter.Canvas(root)
>>> c.pack(expand=1)
>>> mypen=turtle.RawPen(c)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
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'
alex.
More information about the Python-list
mailing list