[Tutor] Turtle problem: how to exit the .exe?

Kent Johnson kent37 at tds.net
Tue Jul 29 12:22:03 CEST 2008


On Mon, Jul 28, 2008 at 4:44 PM, Dick Moores <rdm at rcblue.com> wrote:
> Win XP, Python 2.51
>
> The script is at <http://py77.python.pastebin.com/f414c8ce4>  It calls the
> Windows console to show the printed data.
>
> I've successfully used PyInstaller to make an .exe for this.  For informed
> users, exiting the program before it finishes is easily and cleanly done by
> a Ctrl+Q on the console window.
>
> But I'd like to make a version of the script that doesn't report any data.
> How can I write it so that the .exe can be easily exited by the user? If
> Tkinter instead of Turtle were involved, I could have an Exit button
> connected to command=root.quit .

Take a look at the source for the turtle module (in
Python/Lib/lib-tk/turtle.py I think). It has a global _root object
which is the Tk instance.

You could make your own Pen class, subclassing from RawPen, that makes
whatever kind of window you would prefer. Then instead of using the
module functions forward(), down(), etc - which just delegate to a
global Pen instance - make an instance of your own pen and draw with
that.

Kent


More information about the Tutor mailing list