# Draws many rectangles at random x/y positions # filled in with randomly chosen colors. import random from DrawingPanel import * # constants WIDTH = 300 HEIGHT = 200 SIZE = 30 NUM_RECTS = 20 def main(): panel = DrawingPanel(WIDTH, HEIGHT) for i in range(NUM_RECTS): # choose random rectangle location x = random.randint(0, WIDTH - SIZE) y = random.randint(0, HEIGHT - SIZE) # create a random RGB color for the rectangle red = random.randint(0, 255) green = random.randint(0, 255) blue = random.randint(0, 255) panel.fill_rect(x, y, SIZE, SIZE, (red, green, blue)) main()