/* jquery */ /* jquery accordion style*/ /* jquery init */

4 May 2013

Learn Python - The Turtle Module

So, how do we access all this fun with Python? Well, it's all down to a module called turtle, which has a collection of Logo-like commands, implemented as functions - plus some useful window and event management features.

The turtle module's functionality is split into a number of categories. In broad terms these are:

 turtle movement
 pen control
 colour and fill settings
special shapes
window management
event handling

Installation

Is the turtle module already installed? You can easily check this out in a Python interactive session.

Start a new session and enter this statement:

>>> import turtle

If you see an error message about a missing module, don't worry, just follow these installation instructions.Note: these instructions presume you're running the standard Debian Linux image.

Make sure your Raspberry Pi is connected to the Internet, then open a Terminal window and type the following command:

sudo apt-get install python-tk

If prompted enter the password you used to login in with, and reply y to any prompts.

The turtle module is based on the Tkinter module we used previously for our GUI apps (see my Installing Tkinter post.

Now let's start working with turtle graphics.

A post from my Learn Python on the Raspberry Pi tutorial.