O'Reilly logo

Python Programming with the Java™ Class Libraries: A Tutorial for Building Web and Enterprise Applications with Jython by Richard Hightower

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Complete Shapes and DrawShapes Modules

We've covered all of the classes. At this point, you may want to run the Shapes and DrawShapes modules to see the drawing package in action. Here's the Shapes module.

 class Shape: def __init__(self, x, y, width=0, height=0, color=None, fill=0): self.x=x self.y=y self.width=width self.height=height self.color=color self.fill=fill def paint(self, graphics): if not self.color is None: oldcolor = graphics.foregroundColor graphics.color = self.color if self.fill: self.draw_filled(graphics) else: self.draw_outline(graphics) if not self.color is None: graphics.color = oldcolor def draw_filled(self, graphics): pass def draw_outline(self, graphics): pass def getRect(self): return self.x, self.y, self.width, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required