12.4 Basic Implementation

Let’s begin with a top-down implementation of the portion of the class hierarchy needed to implement the program in Listing 12.2. We will start with the Canvas class (shown in LISTING 12.3), which serves the same purpose for our graphics module as it does for the turtle. It is a place for us to draw GeometricObjects. In fact, because we are using the turtle to do all of our behind-the-scenes drawing, we will make use of the same window and canvas as the turtle. This decision saves us a lot of work but also has some important ramifications for our program. For example, it means that we will use the turtle’s coordinate system.

LISTING 12.3 The Canvas class

12.4.1 The Canvas Class

The most difficult task in writing ...

Get Python Programming in Context, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.