I am currently working on the second edition of my introductory textbook, Python Programming: An Introduction to Computer Science. It will be the same book (with a bit of re-ordering), but updated to use Python 3.x. Here are a couple of resources for use with the new book:
This is a Browseable directory of the example code updated for Python 3.x. Note that chapters 4 and 5 are swapped from the first edition of the book.
A zip file of all the code examples for easy download.
This is an update of the simple graphics library that is used in the book. This version of graphics should work without modification for both 2.x and 3.x versions of Python.
The API of the graphics library has not changed, but the architecture has been streamlined. I have decided to drop the running of graphics commands in a separate thread (introduced in version 3.0 of the original library). The only advantage of that approach was a more seamless experience when using the library interactively from the IDLE shell. The disadvantages turned out to be many, including: poorer performance, brittleness, and the inability to use the graphics library in programs that incorporate direct calls to tkinter.
The library should now work more robustly in a wide range of environments, including direct interaction from command-line Python on all three major platforms (Linux, MacOS, and Windows). When attempting to use the library interactively in some development environments (e.g. the IDLE shell) a graphics window may appear unresponsive until it is explicitly updated. To simplify these interactions, I have added a top-level update() function that flushes the TK event queue. So you can still experiment in IDLE by using interactions like this:
>>> from graphics import *
>>> w = GraphWin()
>>> c = Circle(Point(100,100), 50)
>>> c.draw(w)
>>> update()
>>> c.setFill("red")
>>> update()
The explicit calls to update will show changes that have been
made to any graphics windows.
An alternative work-around it to start up IDLE with the -n (no
subprocess) switch. Then the calls to update() are not
necessary.
Note: that non-interactive uses of the library should be unaffected by the change in architecture, except that you may notice significant performance gains. As a result, you might need to put explicit updates and/or delays in certain animation loops.
This is the legacy (threaded) version of the graphics library, ported to Python 3. This is provided for those who feel they absolutely need to exact behavior of the old library. I strongly discourage it's use.
Related Links: