Drawing Tool - Bonus
This solution is too big to print directly in the book, so can be found over on the github repository. Here is a short link to it: https://rb.gy/tp9qe
Let's go through the code step by step to understand how it works:
- The code begins by importing the pygame, sys, and product modules. Pygame for game development, sys for system-specific parameters and functions, and product is used to generate cartesian products. The pygame library is initialised by calling pygame.init().
- The DrawingTools class is defined with two class-level variables: PAINT_BRUSH and LINE_TOOL. These variables represent different drawing tools available in the program.
- The ActionButtons class is defined with four class-level variables: CLEAR_CANVAS, ...
Get Programming Puzzles: Python 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.