IDLE and turtle

Gregor Lingl glingl at aon.at
Mon Mar 22 12:58:25 EST 2004



dbrown2 at yahoo.com schrieb:
> I typically use IDLE for editing and debug.  On Windows at least, IDLE
> and the standard turtle graphics module do not mix.  I think both use
> Tkinter.
> 
> For now I use IPython and Jedit when using the turtle module but it's
> not a great solution for me.  Is there any known work-around to use
> turtle with IDLE?  If not is there a planned fix for the problem.  I
> find turtle is a convenient way to do simple graphics without having
> to install external modules or deal with event handlers or windowing
> details.
> 
> -- David

With Python 2.2 and IDLE 0.8 it was no problem to use turtle.py (and
Tkinter in general) interactively, because tha application and IDLE
itself ran in the same process (using the same mainloop()).

As this turned out to be a problem when writing programs of some
complextiy the decision was made to change the way IDLE runs
programs, namely in their own processes with their own namespaces.

*Un*fortunately this proved to be a problem for interactively using
and exploring Tkinter.

*Fortunately* there is a way to use the new IDLE 1.0 exactly the
same way as the old IDLE 0.8: to use it with the -n option.

Under Windows e. g. you have to change the link which calls IDLE as
follows (or similar):

C:\Python23\pythonw.exe "C:\Python23\Lib\idlelib\idle.pyw " -n

This makes IDLE starting up without subprocesses, which is indicated
by the message

IDLE 1.0.2      ==== No Subprocess ====
 >>>

in the Shell window. This way you can execute turtle graphics commands
immediately and also explore and construct GUIs with Tkinter interactively.

But keep in mind, that this makes program development more error prone.
Normally this does not matter when developing tiny turtle graphics
programs.

I use to use two versions of IDLE (and I have two coresponding icons
on my desktop). The one with the -n - option for interactive explorations,
the other one, configured like it comes out of the box, for developing
more complex programs.

HTH, Gregor



More information about the Python-list mailing list