Chapter 9 introduced simple tkinter animation techniques (see the
canvasDraw variants). The
PyDraw program listed here builds upon those ideas to implement a more
feature-rich painting program in Python. It adds new trails and
scribble drawing modes, object and background color fills, embedded
photos, and more. In addition, it implements object movement and
animation techniques—drawn objects may be moved around the canvas by
clicking and dragging, and any drawn object can be gradually moved
across the screen to a target location clicked with the mouse.
PyDraw is essentially a tkinter canvas with keyboard and mouse event bindings to allow users to perform common drawing operations. This isn’t a professional-grade paint program, but it’s fun to play with. In fact, you really should—it is impossible to capture things such as object motion in this book. Start PyDraw from the launcher bars (or run the file movingpics.py from Example 11-8 directly). Press the ? key to view a help message giving available commands (or read the help string in the code listings).
Figure 11-17 shows PyDraw after a few objects have been drawn on the canvas. To move any object shown here, either click it with the middle mouse button and drag to move it with the mouse cursor, or middle-click the object, and then right-click in the spot you want it to move toward. In the latter case, PyDraw performs an animated (gradual) movement of the object to the target ...