Python Resources

Updated on Feb 5 2022

Python In Other Contexts

Deborah R. Fowler



Python in other contexts (cool things to do with python involving graphics of course!)

Updated on March 28  2013
Updated on April 19  2020 for Python 3.6 PIL and April 25 for Mac install of PIL (pillow)
Updated on July 17 2020 for Python 3.8 PIL
Updated on Jan 15  2021 with links to 3.8 docs
Updated on June 12  2021 split off PIL and OpenCV
Updated on Jan 23  2021 example of PIL to do pixel art
Updated on April 28  2022 link to pygame updated


houdini

turtle turtle graphics is a popular way to introduce programming to kids (part of logo language in the 60's). For example:
    import turtle                
    t = turtle.Pen()             # opens a window for drawing
    t.forward(100)
    t.right(25)
    and so on, for a list of functions (methods) click here, for example to go foward without drawing would be t.penup() and t.forward(100)
Turtle geometry is one way to describe L-systems.
More information here.

Tkinter this is python's standard graphics user interface (GUI) package. It is Tcl/Tk. The Tkinter page has a decent set of instructions to see if it will work on your machine. You can find some great examples on the website corresponding to Python for Kids here and click on Download the sample code from the book. (Note - test your tkinter - if it's like my machine you'll have to change the printimport calls from tkinter to Tkinter and then they will work fine).

pygame this is implemented as a set of modules on top of the SDL library. Follow the tutorial instructions listed here to get a simple bouncing ball. Read about games and python as well.

PyOpenGL/freeglut you can use Python with OpenGL.


PIL Python Image Library

PIL Python Pixel Art with Turtle Graphics


 OpenCV in Python


Useful sites and tips for installing libraries (particularly on Windows 10)

Christoph Gohlke maintains Unofficial Windows Binaries for Python Extension Package
This page is a wealth of easy to install libraries in whl format.

To install a whl file on Windows, start a cmd window and type
C:\PythonVERSION\Scripts\pip install name_of_file.whl
To check your python path in IDLE type
import sys
print sys.path

You can append using append %PATH%;C\: Path_you_want_to_add