def main(): # Set up interface win = GraphWin("Extended Three Button Monte", 350, 350) win.setCoords(.5,-2, 3.5, 3) b1 = Button(win, Point(1,2), .75, 1, "Door 1") b1.activate() b2 = Button(win, Point(2,2), .75, 1, "Door 2") b2.activate() b3 = Button(win, Point(3,2), .75, 1, "Door 3") b3.activate() again = Button(win, Point(1.25,0), 1, .75, "Play Again") quit = Button(win, Point(2.75,0), 1, .75, "Quit") mess = Text(Point(2,.75), "Guess a door") mess.setStyle("bold") mess.draw(win) scoreBox = Text(Point(2,-1), "") scoreBox.draw(win) playAgain = True hits = 0 misses = 0 while playAgain: mess.setText("Guess a door") pick = getDoorPick(win, b1, b2, b3) hits, misses = updateScore(pick, mess, scoreBox, hits, misses) playAgain = quitOrPlay(win, quit, again) win.close()
def main(): win = GraphWin("Face", 600, 400) win.setCoords(0,0,15,15) pt = win.getMouse() face = Face(win, pt, 3) bWink = Button(face.window, Point(13, 13), 3, 1, "Wink") bWink.activate() quitButton = Button(face.window, Point(13, 2), 3, 1, "Quit") quitButton.activate() while not quitButton.clicked(pt): if bWink.clicked(pt): face.wink() pt = win.getMouse()