Graphical Python Programming part 2: Write Your Own Screensaver

669
In part 1 In part I, you learned how to use Python and PyGTK to bring up a window and draw lines and circles. Let’s take that example and extend it to draw some pretty graphics.

You’ve already seen that you can draw a line in your PyGTK app like this:

 

widget.window.draw_line(xgc, x1, y1, x2, y2)

The color, line thickness and line style will all be taken from whatever you’ve set in xgc, your graphics context.

You can use that to make some whizzy color-changing graphics — lines constantly redrawing in different positions and colors. You could make a screensaver! See the rest of this excellent howto by ace coder Akkana Peck at LinuxPlanet.