#!/usr/bin/env python """ Graphics program that lets the user click three times and then draws a red triangle there. """ from graphics import * def say(string, win, which_line): where = Point(100, 20 + 20 * which_line) text = Text(where, string) text.draw(win) def get_point(win, which_line): point = win.getMouse() message = 'You clicked at ' + \ str(point.getX()) + ' ' + \ str(point.getY()) say(message, win, which_line) return point # --- didn't work # def unsay(string): # where = Point(100,20) # text = Text(where, string) # text.undraw() def main(): window = GraphWin("Triangle Demo", 700, 700) say('Please click three times.', window, 0) point1 = get_point(window, 1) point2 = get_point(window, 2) point3 = get_point(window, 3) triangle = Polygon(point1, point2, point3) triangle.setFill('red') triangle.draw(window) string = input('type something') main()