from graphics import * from button import * import random def drawDot(x, y, color, win): c = Circle(Point(x,y), 3) c.setFill(color) c.draw(win) window = GraphWin("Dot Painter 0.1 alpha", 500, 700) # Set the coordinate system so each pixel is 1 unit, and the origin is in # the lower-left corner. window.setCoords(0,0,499,699) close_button = RectangleButton(Point(250, 350), 200, 100, "Close") close_button.draw(window) not_closed_yet = True new_color_button = RectangleButton(Point(450, 650), 50, 50, "??") new_color_button.draw(window) draw_color = color_rgb(0,0,0) while not_closed_yet: click_pos = window.getMouse() if new_color_button.clicked(click_pos): draw_color = color_rgb(random.randrange(256), random.randrange(256), random.randrange(256)) elif close_button.clicked(click_pos): not_closed_yet = False else: drawDot(click_pos.getX(), click_pos.getY(), draw_color, window)