Ejemplo n.º 1
0
def main():
    win = GraphWin('Dice Roller')
    win.setCoords(0, 0, 10, 10)
    win.setBackground('green2')

    die1 = MultiSidedDie(6)
    die2 = MultiSidedDie(6)
    dieView1 = DieView(win, Point(3, 7), 2)
    dieView2 = DieView(win, Point(7, 7), 2)

    rollButton = Button(win, Point(5, 4.5), 6, 1, 'Roll Dice')
    rollButton.activate()

    quitButton = Button(win, Point(5, 1), 2, 1, 'Quit')

    point = win.getMouse()
    while not quitButton.clicked(point):
        if rollButton.clicked(point):
            die1.roll()
            dieView1.drawValue(die1.getValue())
            die2.roll()
            dieView2.drawValue(die2.getValue())
            quitButton.activate()
        point = win.getMouse()

    win.close()
    def help(self):
        helpWin = GraphWin("Help", 600, 400)
        helpWin.setBackground("blue1")

        banner = Text(Point(275, 75), "The Game of Craps:")
        banner.setSize(24)
        banner.setStyle("bold")
        banner.draw(helpWin)

        explanation = [Text(Point(305, 140), "Both dice are always rolled at the same time."),
                       Text(Point(305, 180), "A player places a bet, and then rolls the dice."),
                       Text(Point(355, 220), "A 7 or 11 on the first roll is a win, while a 2, 3, or 12 is a loss."),
                       Text(Point(285, 260), "Otherwise, the player keeps rolling until:"),
                       Text(Point(285, 300), "They re-roll their initial roll (this is a win)"),
                       Text(Point(165, 340), "Or"),
                       Text(Point(245, 380), "They roll a 7 (this is a loss)")]
        for sentence in explanation:
            sentence.draw(helpWin)
            sentence.setSize(16)
            
        closeButton = Button(helpWin, Point(60, 40), 80, 40, "Close Window")
        closeButton.activate()
        p = helpWin.getMouse()
        if closeButton.clicked(p):
            helpWin.close()
Ejemplo n.º 3
0
def main():
    # create GUI window
    win = GraphWin("Deck Display", 600, 400)
    # set window background to green
    win.setBackground("green")
    # create a title banner
    banner = Text(Point(300, 30), "Display Deck of Cards")
    banner.setSize(24)
    banner.setFill("yellow")
    banner.setStyle("bold")
    banner.draw(win)
    # create card display button
    displayCardButton = Button(win, Point(300, 90), 120, 25, "Display Card")
    displayCardButton.activate()
    # create a rectangle placeholder for card image
    rect = Rectangle(Point(225, 130), Point(375, 330))
    rect.setWidth(3)
    rect.draw(win)
    # create "Quit" button
    quitButton = Button(win, Point(300, 370), 120, 25, "Quit")
    quitButton.activate()
    # create a full Deck of cards
    deck = Deck()
    # get mouse click point
    pt = win.getMouse()
    # while the "Quit" button is not clicked
    while not quitButton.clicked(pt):
        # call show deck method
        deck.show(win, pt, quitButton, displayCardButton, rect)
        # check mouse click point again
        pt = win.getMouse()
    # close GUI window
    win.close()
    def help(self):
        helpWin = GraphWin("Help", 600, 400)
        helpWin.setBackground("blue")
        rulesText = Text(Point(300, 30), "Rules of the Game:")
        rulesText.setSize(24)
        rulesText.draw(helpWin)
        rules = [Text(Point(290, 100), "A player starts with $100. Each round costs $10 to play."),
                 Text(Point(230, 140), "A player initially roles a random hand."),
                 Text(Point(300, 180), "Dice can be re-rolled up to two times (any number of dice)."),
                 Text(Point(165, 240), "Payout Schedule:")]
        for rule in rules:
            rule.draw(helpWin)
            rule.setSize(16)
        payouts = [Text(Point(165, 280), "Two Pairs, $5"),
                   Text(Point(170, 300), "Three of a Kind, $8"),
                   Text(Point(165, 320), "Full House, $12"),
                   Text(Point(170, 340), "Four of a Kind, $15"),
                   Text(Point(165, 360), "Straight, $20"),
                   Text(Point(170, 380), "Five of a Kind, $30")]
        for item in payouts:
            item.draw(helpWin)
            item.setSize(16)

        closeButton = Button(helpWin, Point(60, 40), 80, 40, "Close Window")
        closeButton.activate()
        p = helpWin.getMouse()
        if closeButton.clicked(p):
            helpWin.close()
Ejemplo n.º 5
0
def main():
    x = y = 800
    win = GraphWin("Monte Hall doors", x, y)
    win.setCoords(0, 0, x, y)

    quitbutton = Button(win, Point(600, 750), 50, 25, "QUIT")
    quitbutton.activate()
    txt = Text(Point(400, 750), "correctly guessed: {:>5}".format(0))
    txt.draw(win)
    #pt = win.getMouse()
    dr = Montehall(win, x, y)
    guessed = 0
    total = 0
    while True:
        pt = win.getMouse()
        if quitbutton.clicked(pt):  # check for quit button each loop
            break
        random_door = randrange(1, 4)
        dr = Montehall(win, x, y)
        dr.set_value(random_door)
        #pt = win.getMouse()
        dr_n = dr.door_clicked(pt)
        while not dr_n:
            if quitbutton.clicked(pt):  # check for quit button each loop
                break
            pt = win.getMouse()
            dr_n = dr.door_clicked(pt)
        if dr_n == random_door:
            guessed += 1
        total += 1
        txt.setText("correctly guessed: {0:>5}   /{1:>5}".format(
            guessed, total))
Ejemplo n.º 6
0
    def help(self):
        helpWin = GraphWin("Help", 600, 400)
        helpWin.setBackground("blue1")

        banner = Text(Point(275, 75), "The Game of Craps:")
        banner.setSize(24)
        banner.setStyle("bold")
        banner.draw(helpWin)

        explanation = [
            Text(Point(305, 140),
                 "Both dice are always rolled at the same time."),
            Text(Point(305, 180),
                 "A player places a bet, and then rolls the dice."),
            Text(
                Point(300, 220),
                "A 7 or 11 on the first roll is a win, while a 2, 3, or 12 is a loss."
            ),
            Text(Point(305, 260),
                 "Otherwise, the player keeps rolling until:"),
            Text(Point(305, 300),
                 "They re-roll their initial roll (this is a win)"),
            Text(Point(300, 340), "Or"),
            Text(Point(300, 380), "They roll a 7 (this is a loss)")
        ]
        for sentence in explanation:
            sentence.draw(helpWin)
            sentence.setSize(16)

        closeButton = Button(helpWin, Point(65, 30), 110, 40, "Close Window")
        closeButton.activate()
        p = helpWin.getMouse()
        if closeButton.clicked(p):
            helpWin.close()
Ejemplo n.º 7
0
class firstscreen(wind):

    def makeit(self):
        #button to login
        self.butLogin = Button(self.win, Point(5, 5), 4, 1, "Ingresar como usuario")
        self.butLogin.activate()

        #button to create user
        self.butCreate = Button(self.win, Point(5, 3), 4, 1, "Crear usuario")
        #self.butCreate.activate()
        
        

        self.mc = self.win.getMouse()

        while not self.butExit.clicked(self.mc):

            #click in "Log as user"
            if self.butLogin.clicked(self.mc):
                return "logscreen"


            #click in "Create user"
            elif self.butCreate.clicked(self.mc):
                return "createscreen"

            self.mc = self.win.getMouse()

        return "salir"
def main():

    # create the application window
    win = GraphWin("Dice Roller")
    win.setCoords(0, 0, 10, 10)
    win.setBackground("green2")

    # Draw the interface widgets
    die1 = DieView(win, Point(3,7), 2)
    die2 = DieView(win, Point(7,7), 2)
    rollButton = Button(win, Point(5,4.5), 6, 1, "Roll Dice")
    rollButton.activate()
    quitButton = Button(win, Point(5,1), 2, 1, "Quit")

    # Event loop
    pt = win.getMouse()
    while not quitButton.clicked(pt):
        if rollButton.clicked(pt):
            value1 = randrange(1,7)
            die1.setValue(value1)
            value2 = randrange(1,7)
            die2.setValue(value2)
            quitButton.activate()
        pt = win.getMouse()

    # close up shop
    win.close()
def main():

    # create application window
    win = GraphWin("Three Door Monte", 600, 400)
    win.setCoords(0, 0, 15, 10)
    win.setBackground("darkgrey")

    # create game
    doorMonte = Game(win)

    # create replay and quit button
    quitbutton = Button(win, Point(11.25, 1), 3, 1.5, "Quit")
    quitbutton.activate()
    replay = Button(win, Point(3.75, 1), 3, 1.5, "Replay")

    # event loop
    click = win.getMouse()
    while not quitbutton.clicked(click):
        if doorMonte.doorPicked(click):
            replay.activate()
        elif replay.clicked(click):
            doorMonte.reset()
        click = win.getMouse()

    win.close()
def main():
    # create the application window
    win = GraphWin("Dice Roller")
    win.setCoords(0, 0, 10, 10)
    win.setBackground("green2")

    # draw the interface widgets
    die1 = DieView(win, Point(3, 7), 2)
    die2 = DieView(win, Point(7, 7), 2)
    rollButton = Button(win, Point(5, 4.5), 6, 1, "Roll Dice")
    rollButton.activate()
    quitButton = Button(win, Point(5, 1), 2, 1, "Quit")

    # event loop
    pt = win.getMouse()
    while not quitButton.clicked(pt):
        if rollButton.clicked(pt):
            red = randrange(0, 256)
            green = randrange(0, 256)
            blue = randrange(0, 256)
            color = color_rgb(red, green, blue)
            value1 = randrange(1, 7)
            die1.setValue(value1)
            die1.setColor(color)
            value2 = randrange(1, 7)
            die2.setValue(value2)
            die2.setColor(color)
            quitButton.activate()
        pt = win.getMouse()

    # close up shop
    win.close()
Ejemplo n.º 11
0
def main():

    # Create Application Window
    win = GraphWin("Height Estimator", 400, 400)
    win.setCoords(0, 0, 10, 10)
    win.setBackground("white")

    # Run intro
    intro(win)

    # Build inputs
    # Request child gender and height of parents via GUI
    Text(Point(3, 7), "Input gender of child as 'm' or 'f'?").draw(win)
    gender = Entry(Point(8, 7), 5).draw(win)

    Text(Point(3, 6), "What is the height of the mother?").draw(win)
    momHeightVal = Entry(Point(8, 6), 5).draw(win)

    Text(Point(3, 5), "What is the height of the father?").draw(win)
    dadHeightVal = Entry(Point(8, 5), 5).draw(win)

    # Create buttons and activate 'submit' button
    submit = Button(win, Point(5, 3), 2, 1, "Submit")
    submit.activate()
    quit = Button(win, Point(5, 1), 2, 1, "Quit")

    # Allow user to provide inputs and wait for click
    pt = win.getMouse()

    # While user did not click the 'quit' button
    while not quit.clicked(pt):
        # If the user clicked the 'submit' button
        if submit.clicked(pt):
            # Translate inputs into readable nums and chars
            # Try compiling information
            try:
                childGender = gender.getText()
                momHeight = eval(momHeightVal.getText())
                dadHeight = eval(dadHeightVal.getText())

                # Run the appropriate function depending on gender input
                if childGender == "m":
                    maleChild(win, momHeight, dadHeight)
                elif childGender == "f":
                    femaleChild(win, momHeight, dadHeight)
                else:
                    print("Please input a valid gender")
            # If missing fields, display error message
            except:
                Text(
                    Point(5, 2),
                    "Please fill in all inputs with valid values after restarting the program"
                ).draw(win)
            # Activate quit button after one loop
            quit.activate()
            submit.deactivate()
        # Determine where user clicks and repeate loop if not 'quit' button
        pt = win.getMouse()
    # Close the program if 'quit' button
    win.close()
Ejemplo n.º 12
0
def main():
    #create the application window
    win = GraphWin('Dice Roller')
    win.setCoords(0, 0, 10, 10)
    win.setBackground("green2")

    # draw the interface widget
    die1 = DieView(win, Point(3,7), 2)
    die2 = DieView(win, Point(7,7), 2)
    rollButton = Button(win, Point(5,4.5), 6, 1, "Roll Dice")
    rollButton.activate()
    quitButton = Button(win, Point(5,1), 2, 1, "Quit")

    # Event loop
    pt = win.getMouse()
    try:
        while not quitButton.clicked(pt):
            if rollButton.clicked(pt):
                value1 = randrange(1,7)
                die1.setValue(value1)
                value2 = randrange(1,7)
                die2.setValue(value2)
                quitButton.activate()
            pt = win.getMouse()

        # close up shop
        win.close()
    except GraphicsError as g:
        print(g)
Ejemplo n.º 13
0
def main():
    win = GraphWin("Dice Poker", 600, 400)
    win.setBackground("green3")
    banner = Text(Point(300, 30), "Python Poker Parlor")
    banner.setSize(24)
    banner.setFill("yellow2")
    banner.setStyle("bold")
    banner.draw(win)
    letsPlayBtn = Button(win, Point(300, 300), 400, 40, "Let's Play!")
    letsPlayBtn.activate()
    exitBtn = Button(win, Point(300, 350), 400, 40, "Exit")
    exitBtn.activate()
    showHighScores(win)

    while True:
        p = win.getMouse()

        if letsPlayBtn.clicked(p):
            win.close()
            inter = GraphicsInterface()
            app = PokerApp(inter)
            app.run()
            break

        if exitBtn.clicked(p):
            win.close()
            break
Ejemplo n.º 14
0
def main():

    # create the application window
    win = GraphWin("Dice Roller")
    win.setCoords(0, 0, 10, 10)
    win.setBackground("teal")

    # Draw the interface widgets
    die1 = DieView(win, Point(3,7), 2)
    die2 = DieView(win, Point(7,7), 2)
    rollButton = Button(win, Point(5,4.5), 9, 1, "Click To Roll Dice")
    rollButton.activate()
    quitButton = Button(win, Point(5,1), 2, 1, "Quit")

    # Event loop
    pt = win.getMouse()
    while not quitButton.clicked(pt):
        if rollButton.clicked(pt):
            value1 = randrange(1,7)
            die1.setValue(value1)
            value2 = randrange(1,7)
            die2.setValue(value2)
            quitButton.activate()
        pt = win.getMouse()

    # close up shop
    win.close()
Ejemplo n.º 15
0
	def chooseDice(self):
		# choices is a list of the indexes of the selected dice
		choices = []	# No dice chosen yet
		while True:
			# Wait for user to click a valid button
			b = self.choose(["Die 1", "Die 2", "Die 3", "Die 4", "Die 5", 
							"Roll Dice", "Score", "Help"])
			if b[0] == "D":			# User clicked a die button
				i = eval(b[4]) - 1	# Translate label to die index
				if i in choices:	# Currently selected, unselect it
					choices.remove(i)
					self.dice[i].setColor("black")
				else:				# Currently unselected, select it
					choices.append(i)
					self.dice[i].setColor("red")
			else: 					# User clicked roll or score
				for d in self.dice:	# Revert appearance of all dice
					d.setColor("black")
				if b == "Score":	# Score clicked, ignore choices
					return []
				elif b == "Help":	# Help clicked, popup window
					helpWin = GraphWin("Dice Poker Help", 360, 400)
					helpWin.setBackground("green3")
					# Create Help Header
					header = Text(Point(180,30), "Rules")
					header.setSize(24)
					header.setFill("yellow2")
					header.setStyle("bold")
					header.draw(helpWin)
					# Display rules to window
					rule2 = Text(Point(180,60), "Select `ROLL DICE` to begin.").draw(helpWin)
					rule3 = Text(Point(180,80), "A round costs $10 to play. You begin with $100.").draw(helpWin)
					rule4 = Text(Point(180,100), "Select a Die to reroll. Red dice get rerolled.").draw(helpWin)
					rule5 = Text(Point(180,120), "Reroll die up to two times. Select `SCORE` if no reroll desired").draw(helpWin)
					rule6 = Text(Point(180,140), "Decide to press your luck or cash out from the table.").draw(helpWin)
					rule7 = Text(Point(180,160), "Top high scores are recorded.").draw(helpWin)
					# Display payouts to window
					payout = Text(Point(180,190), "Payouts")
					payout.setSize(24)
					payout.setFill("yellow2")
					payout.setStyle("bold")
					payout.draw(helpWin)
					payouts = ["5", "8", "12", "15", "20", "30"]
					payout1 = Text(Point(180,220), "Two Pair: $" + payouts[0]).draw(helpWin)
					payout2 = Text(Point(180,240), "Three of Kind: $" + payouts[1]).draw(helpWin)
					payout3 = Text(Point(180,260), "Full House: $" + payouts[2]).draw(helpWin)
					payout4 = Text(Point(180,280), "Four of Kind: $" + payouts[3]).draw(helpWin)
					payout5 = Text(Point(180,300), "Straight: $" + payouts[4]).draw(helpWin)
					payout6 = Text(Point(180,320), "Five of Kind: $" + payouts[5]).draw(helpWin)
					exit = Button(helpWin, Point(180, 360), 120, 40, "EXIT")
					exit.activate()
					# Look for where user clicks button
					pt = helpWin.getMouse()
					while not exit.clicked(pt):
						pt = helpWin.getMouse()
					if exit.clicked(pt):
						helpWin.close()

				elif choices != []:	# Don't accept Roll unless some
					return choices	# dice are actually selected
Ejemplo n.º 16
0
 def __drawButtons(self):
     "draw the button to recieve user input"
     coords = [(1.5, .5, 'Play'), (4.5, .5, 'Quit')]
     for x, y, label in coords:
         b = Button(self.win, Point(x, y), .85, .5, label)
         b.activate()
         self.b.append(b)
Ejemplo n.º 17
0
def main():

    # create the application window
    win = GraphWin("Dice Roller", WINDOW_WIDTH, WINDOW_HEIGHT)
    win.setBackground("black")

    # draw the interface widgets
    centerPoint = Point(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2)
    quit = Button(win, Point(WINDOW_WIDTH - 75, WINDOW_HEIGHT - 50), 75, 50,
                  'Quit')
    quit.activate()

    roll = Button(win, Point(WINDOW_WIDTH - 150, WINDOW_HEIGHT - 50), 75, 50,
                  'Roll')
    roll.activate()

    die1 = DieView(win, Point(WINDOW_WIDTH / 2 - 50, WINDOW_HEIGHT / 2), 50)
    die2 = DieView(win, Point(WINDOW_WIDTH / 2 + 50, WINDOW_HEIGHT / 2), 50)

    # event loop
    run = True
    while run:
        clickPoint = win.getMouse()
        if (roll.clicked(clickPoint)):
            die1.setValue(randrange(1, 7))
            die2.setValue(randrange(1, 7))
        run = not quit.clicked(clickPoint)

    # close the window
    win.close()
    def __init__(self):
        self.win = GraphWin("Dice Poker", 600, 400)
        self.win.setBackground("green3")

        banner = Text(Point(300,30), "Python Poker Parlor")
        banner.setSize(24)
        banner.setFill("yellow2")
        banner.setStyle("bold")
        banner.draw(self.win)

        self.msg = Text(Point(300,380), "Welcome to the Dice Table")
        self.msg.setSize(18)
        self.msg.draw(self.win)

        self.createDice(Point(300, 100), 75)
        self.buttons = []
        self.addDiceButtons(Point(300, 170), 75, 30)
        b = Button(self.win, Point(300, 230), 400, 40, "Roll Dice")
        self.buttons.append(b)
        b = Button(self.win, Point(300, 280), 150, 40, "Score")
        self.buttons.append(b)
        b = Button(self.win, Point(570, 375), 40, 30, "Quit")
        self.buttons.append(b)
        
        # Create Help button
        b = Button(self.win, Point(30, 375), 40, 30, "Help")
        self.buttons.append(b)
        b.activate()

        self.money = Text(Point(300, 325), "$100")
        self.money.setSize(18)
        self.money.draw(self.win)
Ejemplo n.º 19
0
 def run(self):
     while self.money >= 10 and self.interface.wantToPlay():
         self.playRound()
     scoreboard = Scoreboard()
     for score in scoreboard.top10:
         if self.money > int(score.score):
             win2 = GraphWin("Dice Poker", 600, 400)
             win2.setBackground("green3")
             banner = Text(Point(300, 30),
                           "New High Score!\nPlease enter your name:")
             banner.setSize(24)
             banner.setFill("yellow2")
             banner.setStyle("bold")
             banner.draw(win2)
             textbox = Entry(Point(300, 150), 30)
             textbox.draw(win2)
             enter_btn = Button(win2, Point(300, 200), 60, 30, "Enter")
             enter_btn.activate()
             p = win2.getMouse()
             playerName = str(textbox.getText())
             if enter_btn.clicked(p):
                 scoreboard.addScore(playerName, self.money)
                 scoreboard.sortScores()
                 scoreboard.saveScores()
                 break
     self.interface.close()
Ejemplo n.º 20
0
def main():
    #create app window
    win = GraphWin("Dice Roller")
    win.setCoords(0, 0, 10, 10)
    win.setBackground('green2')

    #draw interface widgets
    die1 = DieView(win, Point(3, 7), 2)
    die2 = DieView(win, Point(7, 7), 2)
    rollButton = Button(win, Point(5, 4.5), 6, 1, 'Roll Dice')
    rollButton.activate()
    quitButton = Button(win, Point(5, 1), 2, 1, 'Quit')

    #event loop
    pt = win.getMouse()
    while not quitButton.clicked(pt):
        if rollButton.clicked(pt):
            value1 = randrange(1, 7)
            die1.setValue(value1)
            value2 = randrange(1, 7)
            die2.setValue(value2)
            quitButton.activate()
        pt = win.getMouse()

    #close shope
    win.close()
Ejemplo n.º 21
0
    def __init__(self):
        self.win = GraphWin("rules", 800, 240)
        self.win.setBackground("green3")

        banner = Text(Point(400, 30), "Rules")
        banner.setSize(25)
        banner.setFill("yellow2")
        banner.setStyle("bold")
        banner.draw(self.win)

        self.msg1 = Text(Point(400, 60), "1 The player starts with $100. ")
        self.msg1.setSize(15)
        self.msg1.draw(self.win)

        self.msg2 = Text(Point(400, 90), "2 Each round costs $10 to play. This amount is subtracted from the player's ")
        self.msg2.setSize(15)
        self.msg2.draw(self.win)

        self.msg3 = Text(Point(400, 120), "money at the start of the round.  ")
        self.msg3.setSize(15)
        self.msg3.draw(self.win)

        self.msg4 = Text(Point(400, 150), "3 The player initially rolls a completely random hand (i.e., all five dice are rolled). ")
        self.msg4.setSize(15)
        self.msg4.draw(self.win)

        self.msg5 = Text(Point(400, 180), "4 The player gets two chances to enhance the hand by rerolling some or all of the dice. ")
        self.msg5.setSize(15)
        self.msg5.draw(self.win)

        self.buttons = []
        b = Button(self.win, Point(400, 215), 40, 30, "Exit")
        b.activate()
        self.buttons.append(b)
Ejemplo n.º 22
0
class loginscreen(wind):
    def makeit(self):
        self.userField = Entry(Point(3, 7), 15)
        self.userField.draw(self.win)
        self.userText = Text(Point(7, 7), "Ingrese su usuario")
        self.userText.draw(self.win)
        self.pwdField = Entry(Point(3, 5), 15)
        self.pwdField.draw(self.win)
        self.pwdText = Text(Point(7, 5), "Ingrese su clave")
        self.pwdText.draw(self.win)

        self.loginButt = Button(self.win, Point(2, 1), 1.3, 1, "Login")
        self.loginButt.activate()

        self.mc = self.win.getMouse()

        while not self.butExit.clicked(self.mc):

            if self.loginButt.clicked(self.mc):

                return [
                    "userlog",
                    self.userField.getText(),
                    self.pwdField.getText()
                ]

            self.mc = self.win.getMouse()

        return "first"

    def error(self):
        messagebox.showinfo("Error", "usuario o clave incorrecto")
Ejemplo n.º 23
0
class InputDialog3:
        """ A custom window for getting simulation values (angle, velocity,
        and height) from the user."""

        def __init__(self, players=0):
            """ Build and display the input window """

            self.win = win = GraphWin("How Many Players", 500, 500)
            win.setCoords(0, 4.5, 4, .5)

            Text(Point(1, 1), "How Many Players?").draw(win)
            self.players = Entry(Point(3, 1), 5).draw(win)
            self.players.setText(str(players))
            self.confirm = Button(win, Point(1, 4), 1.25, .5, "Confirm!")
            self.confirm.activate()

        def getValues(self):
            """ return input values """

            players = float(self.players.getText())
            return players

        def interact(self):
            """ wait for user to click Quit or Fire button
            Returns a string indicating which button was clicker
            """

            while True:
                pt = self.win.getMouse()
                if self.confirm.clicked(pt):
                    return "Confirm"

        def close(self):
            """ close the input window """
            self.win.close()
Ejemplo n.º 24
0
def spellChkGUI():
    # Print window for intro info
    win = GraphWin("Spell Checker 3000", 600, 400)
    win.setBackground("white")
    header = Text(Point(300, 30), "Spell Checker 3000")
    header.setSize(24)
    header.setFill("black")
    header.setStyle("bold")
    header.draw(win)
    inputLabel1 = Text(Point(150, 100), "File to Check: ").draw(win)
    inputLabel2 = Text(Point(150, 170), "Dictionary: ").draw(win)
    inputLabel1.setSize(20)
    inputLabel2.setSize(20)
    inFileNameInput = Entry(Point(450, 100), 15).draw(win)
    dictFileNameInput = Entry(Point(450, 170), 15).draw(win)

    # Create buttons and activate
    spellCheck = Button(win, Point(200, 360), 120, 40, "SPELL CHECK")
    exit = Button(win, Point(400, 360), 120, 40, "EXIT")
    spellCheck.activate()
    exit.activate()

    # Look for where user clicks button
    pt = win.getMouse()
    while not exit.clicked(pt):
        if spellCheck.clicked(pt):
            # Return file names if user clicks 'spell check'
            inFileName = inFileNameInput.getText()
            dictFileName = dictFileNameInput.getText()
            spellCheck.deactivate()
            return (inFileName, dictFileName)
        pt = win.getMouse()
    if exit.clicked(pt):
        sys.exit()
Ejemplo n.º 25
0
class GraphicInterface:

    # the Graphics window
    def __init__(self):

        #Background
        self.win.setBackground("blue")

        #label display
        labelDisplay = Text(Point(400, 40), "Showing the Suit")
        labelDisplay.setSize(24)
        labelDisplay.setFill("green")
        labelDisplay.setStyle("bold")
        labelDisplay.draw(self.win)

        self.textbox = Entry(Point(400, 75), 10)
        self.textbox.draw(self.win)

        #Instructions
        guide = Text(Point(400, 75), 10)
        guide.setStyle("bold")
        guide.draw(self.win)

        self.suit = dict(spade='Spade.ppm',
                         diamond='Diamond.ppm',
                         heart='Hearts.ppm')
        self.win = GraphWin("Card Display", 800, 600)

        self.imgDisplayRect = Rectangle(Point(325, 160), Point(375, 350))
        self.imgDisplayRect.draw(self.win)

        self.suitButton = Button(self.win, Point(400, 125), 100, 20,
                                 "Display Suit")
        self.suitButton.activate()

        self.exitButton = Button(self.win, Point(300, 370), 100, 20, "Quit")
        self.exitButton.activate()

        self.displaySuit()

    def displaySuit(self):

        clicker = self.win.getMouse()

        while not self.exitButton.clicked(clicker):


            if self.suitButton.clicked(clicker) \
                    and self.textbox.getText() != '':

                self.imgDisplayRect.setfill('white')
                inputText = self.textbox.getText()

                suitImage = Image(Point(400, 350), self.suit[inputText])
                suitImage.draw(self.win)

            clicker = self.win.getMouse()

        self.win.close()
Ejemplo n.º 26
0
def quit_button(win):
    QButton = Button(win, Point(0.5, 1.0), 0.5, 0.75, "Quit")
    QButton.activate()
    P = win.getMouse()
    if QButton.clicked(P):
        return True
    else:
        return False
Ejemplo n.º 27
0
def main():
    # Defines a Window
    win = GraphWin("Child Height Calculator", 600, 400)
    win.setBackground("darkgreen")

    # Draw the Instructions
    instruction = Text(Point(285, 100), "Please enter (in inches): ")
    instructionA = Text(Point(160, 140), "Mother's Height")
    instructionB = Text(Point(400, 140), "Father's Height")
    # Enable Instructions
    instruction.draw(win)
    instructionA.draw(win)
    instructionB.draw(win)

    # Draw the Entry Boxes
    motherEntry = Entry(Point(165, 170), 8)
    fatherEntry = Entry(Point(405, 170), 8)
    # Enables the Entry Boxes
    motherEntry.draw(win)
    fatherEntry.draw(win)

    # Draws the Buttons
    maleCalculateButton = Button(win, Point(165, 200), 160, 20,
                                 "Male Calculate")
    maleCalculateButton.activate()
    femaleCalculateButton = Button(win, Point(405, 200), 160, 20,
                                   "Female Calculate")
    femaleCalculateButton.activate()
    quitButton = CButton(win, Point(300, 330), 30, "Quit")
    quitButton.activate()

    # Draws the Output Box
    outputBoxA = Text(Point(300, 230), "Child Height (in): ")
    outputBoxB = Text(Point(300, 260), "Child Height (ft): ")
    # Enables the Output Box
    outputBoxA.draw(win)
    outputBoxB.draw(win)

    while not quitButton.clicked(win.getMouse()):
        try:
            if maleCalculateButton.clicked(win.getMouse()):
                temp = chooseHeightCalculation("male",
                                               int(motherEntry.getText()),
                                               int(fatherEntry.getText()))
                outputBoxA.setText("Child Height (in): " + str(round(temp, 2)))
                outputBoxB.setText("Child Height (ft): " +
                                   str(round(temp / 12, 2)))

            elif femaleCalculateButton.clicked(win.getMouse()):
                temp = chooseHeightCalculation("female",
                                               int(motherEntry.getText()),
                                               int(fatherEntry.getText()))
                outputBoxA.setText("Child Height (in): " + str(round(temp, 2)))
                outputBoxB.setText("Child Height (ft): " +
                                   str(round(temp / 12, 2)))

        except:
            print("Please Enter Numbers into Data before Proceeding")
Ejemplo n.º 28
0
class InputDialog2:

    """ A custom window for getting simulation values (angle, velocity,
    and height) from the user."""

    def __init__(self, players,hands = 0, players_ent = 0):
        """ Build and display the input window """
        increaser = 0
                   
        self.win = win = GraphWin("Black Jack", 500, 500)
        win.setCoords(0,4.5,4,.5)
        
        player_count = len(players)
        Text(Point(1,1), "Players").draw(win)
        self.players_ent = Entry(Point(3,1), 5).draw(win)
        self.players_ent.setText(str(player_count))
        
        self.players = players

        for i in self.players:
            Text(Point(1,1.5+increaser), "Hands").draw(win)
            entry = Entry(Point(3,1.5+increaser), 5).draw(win)
            hand = 0
            entry.setText(str(hand))
            increaser += .5

        self.hand = Button(win, Point(1,4), 1.25, .5, "Hand")
        self.hand.activate()

        self.quit = Button(win, Point(3,4), 1.25, .5, "Quit")
        self.quit.activate()

    def update(self,players,hands):
        """ return input values """
        increaser = 0
        counter = 0
        for i in players:
            entry = Entry(Point(3,1.5+increaser), 5).draw(self.win)
            hand = hands[0+counter]
            entry.setText(str(hand))
            increaser += .5
            counter += 1

    def interact(self):
        """ wait for user to click Quit or Fire button
        Returns a string indicating which button was clicker
        """
        
        while True:
            pt = self.win.getMouse()
            if self.quit.clicked(pt):
                return "Quit"
            if self.hand.clicked(pt):
                return "Hand"

    def close(self):
        """ close the input window """
        self.win.close()
Ejemplo n.º 29
0
def rulesWindow():

    #Create a window that displays the rules of Blackjack.
    rules = GraphWin("Rules", 540, 400)
    rules.setCoords(0, 0, 540, 400)
    rules.setBackground('White')

    #Print the title of the window.
    title = Text(Point(270, 380), 'Basic Rules of Blackjack')
    title.setStyle('bold')
    title.setTextColor('red')
    title.setSize(16)
    title.draw(rules)

    #Print the main text of the window.
    body = Text(Point(270, 350), '  Blackjack is played with the dealer being dealt two cards and the player being')
    body.draw(rules)
    body = Text(Point(270, 330), 'dealt two cards with the goal to get as close to or equal 21 without going over.')
    body.draw(rules)
    body = Text(Point(270, 310), '  If the dealer or the player get what is called a \'blackjack\', which is a')
    body.draw(rules)
    body = Text(Point(270, 290), 'combination of an ace and a 10-card(10, J, Q, K), he or she wins on the first')
    body.draw(rules)
    body = Text(Point(270, 270), 'turn. If both the dealer and the player get blackjack, a \'push\' or a tie occurs.')
    body.draw(rules)
    body = Text(Point(270, 250), '  If neither the dealer or the player get blackjack, play continues. The player')
    body.draw(rules)
    body = Text(Point(270, 230), 'is given a chance to hit to get closer or equal 21 or stand to maintain their')
    body.draw(rules)
    body = Text(Point(270, 210), 'hand in hopes of beating the dealer. If the player\'s hand total exceeds 21, he')
    body.draw(rules)
    body = Text(Point(270, 190), 'or she \'busts\' and loses to the dealer. If the player has 5 cards and is 21')
    body.draw(rules)
    body = Text(Point(270, 170), 'or less, they win with a 5-card charlie. The same applies to the dealer. Once')
    body.draw(rules)
    body = Text(Point(270, 150), 'the player chooses to stand, play switches to the dealer.')
    body.draw(rules)
    body = Text(Point(270, 130), '  The dealer must also follow the same rules as the player. Once both')
    body.draw(rules)
    body = Text(Point(270, 110), 'sides stand, the dealer and the player compare cards and whoever has the ')
    body.draw(rules)
    body = Text(Point(270, 90), 'highest total wins! If both players have the same total, they \'push\' or tie.')
    body.draw(rules)

    #Create a button that when clicked closes the rules window.
    closeButton = Button(rules, Point(270, 40), 70, 40, 'Got it!')
    closeButton.activate()

    #Get where the user clicked the mouse.
    mouseClick = rules.getMouse()

    #If the user did not click the button, wait on another click.
    while not closeButton.clicked(mouseClick):
        mouseClick = rules.getMouse()

    #Close the rules window.
    rules.close()
Ejemplo n.º 30
0
def playgame(win, type):

    win.setBackground("forest green")

    # call to function to get number of players and class player for each
    numplayers, players = getplayers(win)

    nomlabels = [
        Text(Point(110, 50), players[0].getname()),
        Text(Point(110, 45), players[1].getname()),
        Text(Point(110, 40), players[2].getname()),
        Text(Point(110, 35), players[3].getname()),
        Text(Point(110, 30), players[4].getname()),
        Text(Point(110, 25), players[5].getname()),
    ]
    for i in range(numplayers):
        nomlabels[i].setSize(15)
        nomlabels[i].setStyle("bold")
        nomlabels[i].setTextColor("white")
        nomlabels[i].draw(win)
    quitbutton = Button(win, Point(110, 5), 7, 5, "Quit")

    # plays one series of rounds equal to the number of players,
    # where each player has a go at rolling first
    pt = win.getMouse()
    while not quitbutton.clicked(pt):
        carryover = 0

        for i in range(numplayers):
            starter = i
            carryover = playoneround(win, type, numplayers, players, starter, carryover)

        coinlabels = refreshplayers(players)
        for i in range(numplayers):
            coinlabels[i].draw(win)

        againmsg = Text(Point(50, 50), "Play another series of round?")
        againmsg.setTextColor("white")
        againmsg.setSize(15)
        againmsg.setStyle("bold")
        againmsg.draw(win)

        againbutton = Button(win, Point(35, 40), 15, 7.5, "Again")
        againbutton.activate()
        quitbutton.activate()

        pt = win.getMouse()
        if againbutton.clicked(pt):
            againbutton.destroy()
            quitbutton.deactivate()
            for i in range(numplayers):
                coinlabels[i].undraw()
            againmsg.undraw()
        pt = win.getMouse()

    win.close()
Ejemplo n.º 31
0
def main():
          win = GraphWin()
          win.setCoords(0,0,10,10)
          win.setBackground("green2")

          quitButton = Button(win,Point(5,1),2,1,"Quit")
          quitButton.activate()
          pt = win.getMouse()
          if quitButton.clicked(pt):
                    win.close()
Ejemplo n.º 32
0
class HelpScreen():
    def __init__(self, msg_list):
        """
        HelpScreen class for the GUI Dice Poker game
        :param msg: list -> lines of text to display [[line 1, font size], [line 2, font size], ...]
        """
        winH = 0
        winW = 400
        for line in msg_list:
            winH += line[1] + line[1] / 2   # font size plus half for line spacing
        winH += 70      # to allow for close button
        self.win = GraphWin("Help for Dice Poker", winW, winH)
        self.win.setBackground(color_rgb(80, 0, 0))

        # display lines of help text
        line_pos = 30
        prev_line_ht = msg_list[0][1]

        # first line is heading
        self.display_msg(winW/2, line_pos, msg_list[0][0], 'white', 'white', prev_line_ht)
        prev_line_ht = prev_line_ht / 2
        for line in msg_list[1:]:
            line_pos += prev_line_ht/3 + line[1]
            self.display_msg(winW/2, line_pos+prev_line_ht+line[1], line[0], 'white', 'white', line[1])
            prev_line_ht = line[1]
        self.button_close = Button(self.win, Point(winW/2, winH-40), 75, 35, "Close")
        self.button_close.activate()

    def display_msg(self, x, y, m, c, o, s):
        """
        Helper method to display a message
        :param x: int/float -> x coordinate for center point of message
        :param y: int/float -> y coordinate for center point of message
        :param m: str -> message to display
        :param c: str -> fill color of message
        :param o: str -> outline color of message
        :param s: int -> size of message text
        """
        msg = Text(Point(x, y), m)
        msg.setFill(c)
        msg.setOutline(o)
        msg.setSize(s)
        msg.draw(self.win)

    def get_response(self):
        """
        Event loop to get response from user (clicking the button or pressing Return or Escape)
        :return: boolean -> True when Close is selected
        """
        while True:
            p = self.win.checkMouse()
            k = self.win.checkKey()
            if p and self.button_close.clicked(p) or k == "Return" or k == "Escape":
                self.win.close()
                return True
Ejemplo n.º 33
0
def main():
    # Reads in images to List
    suitList = ["club.ppm", "spade.ppm", "heart.ppm", "diamond.ppm"]

    # Defines a Window
    win = GraphWin("Child Height Calculator", 600, 400)
    win.setBackground("darkgreen")

    # Draw the Instructions
    instructionSuit = Text(Point(100, 40), "Please enter Suit: ")
    instructionSuit.draw(win)

    # Draw the Entry Boxes
    entrySuit = Entry(Point(100, 70), 8)
    entrySuit.draw(win)

    # Makes Process Button
    processButton = Button(win, Point(100, 220), 80, 20, "Draw")
    processButton.activate()

    # Makes Quit Button
    quitButton = Button(win, Point(100, 290), 80, 20, "Quit")
    quitButton.activate()

    # Primary Loop
    while not quitButton.clicked(win.getMouse()):
        try:
            if processButton.clicked(win.getMouse()):
                suit = entrySuit.getText().lower()

                # Draws outline of the card
                cardOutline = Rectangle(Point(230, 50), Point(440, 360))
                cardOutline.setFill("white")
                cardOutline.draw(win)

                if suit.startswith("club"):
                    # Draw Club
                    tempImage = Image(Point(332, 200), suitList[0])

                elif suit.startswith("spade"):
                    # Draw Spade
                    tempImage = Image(Point(332, 200), suitList[1])

                elif suit.startswith("heart"):
                    # Draw Heart
                    tempImage = Image(Point(332, 200), suitList[2])

                elif suit.startswith("diamond"):
                    # Draw Diamond
                    tempImage = Image(Point(332, 200), suitList[3])

                tempImage.draw(win)

        except:
            print("Please Enter valid Suit Name!")
Ejemplo n.º 34
0
class InputDialog:
    """
	A custom window for getting simulation values (angle, velocity, and height) from the user.
	"""
    def __init__(self, angle, vel, height):
        """
		Build and display the input window
		"""
        self.win = win = GraphWin("Initial Values", 200, 300)
        win.setCoords(0, 4.5, 4, .5)

        Text(Point(1, 1), "Angle").draw(win)
        self.angle = Entry(Point(3, 1), 5).draw(win)
        self.angle.setText(str(angle))

        Text(Point(1, 2), "Velocity").draw(win)
        self.vel = Entry(Point(3, 2), 5).draw(win)

        self.vel.setText(str(vel))
        Text(Point(1, 3), "Height").draw(win)
        self.height = Entry(Point(3, 3), 5).draw(win)
        self.height.setText(str(height))

        self.fire = Button(win, Point(1, 4), 1.25, .5, "Fire!")
        self.fire.activate()

        self.quit = Button(win, Point(3, 4), 1.25, .5, "Quit")
        self.quit.activate()

    def interact(self):
        """
		wait for user to click Quit or Fire button Returns a string indicating which button was clicked
		"""
        while True:
            pt = self.win.getMouse()
            if self.quit.clicked(pt):
                return "Quit"
            if self.fire.clicked(pt):
                return "Fire!"

    def getValues(self):
        """
		return input values
		"""
        a = float(self.angle.getText())
        v = float(self.vel.getText())
        h = float(self.height.getText())
        return a, v, h

    def close(self):
        """
		close the input window
		"""
        self.win.close()
Ejemplo n.º 35
0
def makeButtons(win):
    grimButton = Button(win, Point(75, 75), 100, 25, "Grim Face")
    grimButton.activate()
    smileButton = Button(win, Point(75, 375), 100, 25, "Smiley Face")
    smileButton.activate()
    quitButton = Button(win, Point(200, 375), 75, 25, "Quit")
    quitButton.activate()
    winkButton = Button(win, Point(300, 75), 100, 25, "Winking Face")
    winkButton.activate()
    frownButton = Button(win, Point(300, 375), 100, 25, "Frowney Face")
    frownButton.activate()
    return grimButton, smileButton, winkButton, frownButton, quitButton
Ejemplo n.º 36
0
def main():
    print("\nThis app graphically plots a regression line")
    win = createLabeledWindow()
    done_close = Button(win, Point(0.5, 0.25), 1, 0.5, "Done")
    done_close.activate()
    SumX, SumY, SumXX, SumXY, n = drawPoints(win)
    m = slopeCalc(SumX, SumY, SumXX, SumXY, n)
    yCalc(SumX, SumY, m, n, win)

    done_close.changeText(win, Point(0.5, 0.25), "Close")
    done_close.deactivate()
    win.getMouse()
Ejemplo n.º 37
0
def main():
    # Create a graphics window
    win = GraphWin("Three Button Monte", 500, 500)
    win.setCoords(0, 0, 6, 5)
    win.setBackground("black")

    # Create and display a score object
    score = Score(win, .45, 4.6)
    score.display_score()

    door1 = Button(win, Point(1,2.5), 1.5, 2, "One")
    door1.activate()
    door2 = Button(win, Point(3,2.5), 1.5, 2, "Two")
    door2.activate()
    door3 = Button(win, Point(5,2.5), 1.5, 2, "Three")
    door3.activate()

    quitButton = Button(win, Point(5.5,.5), .5, .25, "Quit")
    
    pt = win.getMouse()
    while not quitButton.clicked(pt):
        winner = randrange(3)
        if door1.clicked(pt) and winner == 0 or door2.clicked(pt) and winner == 1 or door3.clicked(pt) and winner == 2:
            score.won()
        else:
            if door1.clicked(pt) and winner != 0 or door2.clicked(pt) and winner != 1 or door3.clicked(pt) and winner != 2:
                score.lost()

        score.update_score()
        quitButton.activate()
        pt = win.getMouse()
Ejemplo n.º 38
0
 def processScore(self, score):
     h = HighScores()
     if h.isElgible(score):
         nameentry = GraphWin("Name Entry", 200, 100)
         entry = Entry(Point(50, 50), 10)
         entry.draw(nameentry)
         okbutton = Button(nameentry, Point(150, 50), 90, 50, "Save Name")
         okbutton.activate()
         while 1:
             m = nameentry.getMouse()
             if okbutton.clicked(m):
                 h.addToList(score, entry.getText())
                 nameentry.close()
                 return
Ejemplo n.º 39
0
def win():
    #TODO Allow user to specify and display any number of passphrase labels
    #TODO Allow user to save passphrase list to file
    #TODO Allow user to specify any number of passphrases outputed to file
    #TODO Create a button to enable/disable Quantum Mode

    myWin = GraphWin("QDG: Quantum Diceware Generator", 500, 100)   #constructor statement that instantiates the window object as 'myWin'
    row_lblStatus = Point(200,10)
    row_lblPhrase = Point(250,30)   #specifies a location on the window canvas for use by any object\

    phrase = Passphrase(myWin,row_lblPhrase)

    btnGenerate = Button(myWin, Point(100,70), 75, 20, "Generate")
    btnQuit = Button(myWin, Point(300,70), 75, 20, "Quit")

    btnQuit.activate()
    btnGenerate.activate()

    # Button Event Loop
    pt = myWin.getMouse()
    while not btnQuit.clicked(pt):
        if btnGenerate.clicked(pt):
            btnGenerate.deactivate()
            btnQuit.deactivate()

            phrase.generate()   #uses the generate() method of object: phrase from the class: Passphrase

            btnGenerate.activate()
            btnQuit.activate()
        pt = myWin.getMouse()

    myWin.close()
    sys.exit(0)
Ejemplo n.º 40
0
    def addButton(self, label, func):
        
        # Get button number
        buttonNum = len(self.buttons)

        #Compute ccordinate of button
        x = 1.5 * (buttonNum % 2) + 0.8
        y = 9.5 - 0.6 * (buttonNum //2) 

        #Create button
        button = Button(self.win, Point(x,y), 1.4, 0.5, label)
        button.activate()

        #Add button to list
        self.buttons.append({'button':button, 'func':func} )
Ejemplo n.º 41
0
class HelpScreen:
    def __init__(self):
        self.win = GraphWin("Dice Poker Help", 600, 450)
        self.win.setBackground("white")
        banner = Text(Point(300, 30), "Python  Poker  Parlor Help")
        banner.setSize(24)
        banner.setFill("black")
        banner.setStyle("bold")
        banner.draw(self.win)
        info = Text(Point(300, 60), "This program allows a user to play video poker using dice")
        info.setFill("black")
        info.draw(self.win)
        text = [
            "* The player starts with $100                             ",
            "* Each round costs $10 to play.  This amount is subtracted",
            "  from the user's money at the start of the round         ",
            "* The player initially rolls a completely random hand     ",
            "  (i.e. all five dice are rolled)                         ",
            "* The player gets two chances to enhance the hand by      ",
            "  rerolling some or all of the dice                       ",
            "* At the end of the hand, the player's money is updated   ",
            "  according to the following payout schedule:             ",
            "  Hand                                       Pay          ",
            " ---------------------------------------------------------",
            "  Two Pairs                                  $5           ",
            "  Three of a Kind                            $8           ",
            "  Full House (A Pair and a Three of a kind)  $12          ",
            "  Four of a Kind                             $15          ",
            "  Straight (1-5 or 2-6)                      $20          ",
            "  Five of a Kind                             $30          ",
        ]
        for i in range(0, len(text)):
            startheight = 80

            t = Text(Point(300, startheight + (20 * i)), text[i])
            t.setFace("courier")
            t.draw(self.win)

        self.closebutton = Button(self.win, Point(550, 350), 50, 40, "Close")
        self.closebutton.activate()

    def DoEvents(self):
        while True:
            m = self.win.getMouse()
            if self.closebutton.clicked(m):
                self.win.close()
                return
Ejemplo n.º 42
0
def main ():

    #Create graphics window
    win = GraphWin(400, 400)
    win.setCoords(0.0, 0.0, 10.0, 10.0)

    #Create Message
    message1 = Text(Point(5.0, 9.0),'Welcome to Three Button Monte')
    message1.draw(win)

    #Create buttons
    number1 = Button(win, Point(2.0, 4.0),1.0, 1.0,'Door 1')
    number1.activate()
    number2 = Button(win, Point(5.0, 4.0),1.0, 1.0, 'Door 2')
    number2.activate()
    number3 = Button(win, Point(8.0, 4.0), 1.0, 1.0, 'Door 3')
    number3.activate()

    #Create quit button
    quit_button = Button(win, Point(2.0, 1.0), 2.0, 2.0,'Click to Quit')
    quit_button.activate()

    #Ask user to pick a door
    message2 = Text(Point(5.0, 7.0),'A door has been chosen. Click on a door to guess it. ')
    message2.draw(win)
    pt = win.getMouse()

    #While user has not chosen to quit
    counter = 0
    while not quit_button.clicked(pt):

        if counter != 0:

    #Ask user to pick a door
            message2.setText('Click on another door. ')
            pt = win.getMouse()

    #Report results to user
        x = pickADoor()
        if x == 1 and number1.clicked(pt) == True:
            message1.setText('You picked the correct door! ')
        elif x == 2 and number2.clicked(pt) == True:
            message1.setText('You picked the correct door! ')
        elif x == 3 and number3.clicked(pt) == True:
            message1.setText('You picked the correct door! ')
        else:
            if x == 1:
                message1.setText("You did not pick the correct door. The correct door was 1")
            if x == 2:
                message1.setText("You did not pick the correct door. The correct door was 2")
            if x == 3:
                message1.setText("You did not pick the correct door. The correct door was 3")
        counter += 1

    #Quit program
    win.close()
 def inputNameHighScore(self):
     highScoreWin = GraphWin("HighScore!", 600, 400)
     highScoreWin.setBackground("blue")
     highScoreMsg = Text(Point(300, 125), "You got a high score!")
     highScoreMsg.setSize(24)
     highScoreMsg.draw(highScoreWin)
     inputMsg = Text(Point(150, 250), "Please enter your name with no spaces:")
     inputMsg.setSize(16)
     inputMsg.draw(highScoreWin)
     input = Entry(Point(400, 250), 35)
     input.draw(highScoreWin)
     enterButton = Button(highScoreWin, Point(350, 325), 45, 30, "Enter")
     enterButton.activate()
     highScoreWin.getMouse()
     name = input.getText()
     highScoreWin.close()
     return name
Ejemplo n.º 44
0
def splashScreen():
    firstWin = GraphWin("Dice Poker", 600, 400)
    firstWin.setBackground("blue")

    die = DieView(firstWin, Point(80,180), 100)
    die.setValue(4)
    die2 = DieView(firstWin, Point(520, 270), 100)
    die2.setValue(6)

    TitleMessage = Text(Point(210, 40), "Dice Poker:")
    TitleMessage.setSize(32)
    TitleMessage.draw(firstWin)

    IntroMessage = Text(Point(360, 40), "A dice game")
    IntroMessage.setSize(20)
    IntroMessage.draw(firstWin)

    HighScores = Text(Point(290, 100), "High Scores:")
    HighScores.setSize(20)
    HighScores.draw(firstWin)
    
    playButton = Button(firstWin, Point(520, 50), 120, 60, "Let's Play!")
    exitButton = Button(firstWin, Point(70, 350), 100, 60, "Exit")
    playButton.activate()
    exitButton.activate()

    # Display High Scores
    x = 290
    y = 110
    infile = open('HighScores', 'r')
    for line in infile:
        name, score = line.split()
        y += 25
        msg = Text(Point(x, y), name + ": " + str(score))
        msg.setSize(12)
        msg.draw(firstWin)

    # User chooses to play or exit
    p = firstWin.getMouse()
    if exitButton.clicked(p):
        firstWin.close()
        return False
    elif playButton.clicked(p):
        firstWin.close()
        return True
Ejemplo n.º 45
0
class SplashScreen:
    def __init__(self):
        self.win = GraphWin("Dice Poker", 600, 500)
        self.win.setBackground("white")
        banner = Text(Point(300, 30), "Python  Poker  Parlor")
        banner.setSize(24)
        banner.setFill("black")
        banner.setStyle("bold")
        banner.draw(self.win)
        info = Text(Point(300, 60), "This program allows a user to play video poker using dice")
        info.setFill("black")
        info.draw(self.win)
        self.letsplaybutton = Button(self.win, Point(200, 100), 180, 40, "Let's Play")
        self.letsplaybutton.activate()
        self.exitbutton = Button(self.win, Point(400, 100), 180, 40, "Exit")
        self.exitbutton.activate()

        highscorebanner = Text(Point(300, 150), "High Scores")
        highscorebanner.setSize(24)
        highscorebanner.setFill("black")
        highscorebanner.setStyle("bold")
        highscorebanner.draw(self.win)
        highscores = HighScores()
        scores = highscores.getHighScores()

        if scores == -1:
            Text(Point(300, 180), "No High Scores Available").draw(self.win)
        else:
            for i in range(0, len(scores)):

                Text(Point(300, 200 + (20 * i)), scores[i][1].strip() + ": " + str(scores[i][0]).strip()).draw(self.win)

    def DoEvents(self):
        while True:
            m = self.win.getMouse()
            if self.letsplaybutton.clicked(m):
                return "Play"
            elif self.exitbutton.clicked(m):
                return "Exit"

    def destroy(self):
        self.win.close()
class IntroWindow:
    def __init__(self):
        self.IntroWin = GraphWin("WELCOME", 600, 400)
        self.IntroWin.setBackground("blue")

        banner = Text(Point(290, 65), "Welcome To BankName")
        banner.setSize(32)
        banner.setStyle("bold")
        banner.draw(self.IntroWin)

        self.IDmsg = Text(Point(150, 150), "Please enter your user ID:")
        self.IDmsg.setSize(16)
        self.IDmsg.draw(self.IntroWin)

        self.input1 = Entry(Point(380, 150), 35)
        self.input1.draw(self.IntroWin)

        self.pinMsg = Text(Point(155, 250), "Please enter your pin number:")
        self.pinMsg.setSize(16)
        self.pinMsg.draw(self.IntroWin)

        self.input2 = Entry(Point(385, 250), 35)
        self.input2.draw(self.IntroWin)

        self.EnterButton = Button(self.IntroWin, Point(550, 250), 50, 60, 'Enter')
        self.EnterButton.activate()

    def getInputs(self):
        p = self.IntroWin.getMouse()
        if self.EnterButton.clicked(p):
            username = self.input1.getText()
            pin = self.input2.getText()
        return username, pin

    def incorrectInput(self):
        msg = Text(Point(290, 325), "*Incorrect username or pin number")
        msg.setSize(24)
        msg.setStyle('bold')
        msg.draw(self.IntroWin)

    def close(self):
        self.IntroWin.close()
Ejemplo n.º 47
0
    def __init__(self):
        win = GraphWin("tetrologyology", 400,400)
        win.setBackground("black")

        text = Text(Point(200, 50), "tetrology v0.1")
        text.setSize(18)
        text.setStyle("bold")
        text.setFill("yellow")
        text.draw(win)

        text2 = Text(Point(200, 150), "Joe Hay -- 2011")
        text2.setFill("yellow")
        text2.draw(win)

        ex = Button(win, Point(200, 300), 60, 25, "Exit")
        ex.activate()

        p = win.getMouse()
        while not ex.clicked(p):
            p = win.getMouse()

        win.close()
Ejemplo n.º 48
0
def playsummary(win, type):

    if type == 0:
        # Placeholder would print the rules summary for the against the house version
        rule = Text(Point(60, 50), "Rules placeholder 1")
    # 		rule.draw(win)
    else:
        # Rules summary for play against other players
        rule2 = [
            Text(Point(60, 62.5), "Slye's Dice is a wagering dice game where the players take turns rolling"),
            Text(Point(60, 60), "five 6-sided dice in an attempt to roll the arbitrary number."),
            Text(Point(60, 57.5), "Each player is allowed three attempts."),
            Text(Point(60, 55), "If the arbitrary number appears on any of the dice, the player stops rolling."),
            Text(Point(60, 52.5), "The player's dice are totaled and that number is the player's score or hand."),
            Text(Point(60, 47.5), "If the arbitrary number is low (1-3), then a high score is preferable."),
            Text(Point(60, 45), "If the arbitrary number is high (4-6), then a low score is preferred."),
            Text(Point(60, 40), "The first player to make a hand is allowed to start the betting."),
            Text(
                Point(60, 37.5), "All subsequent players must match that bet in order to continue playing in the round."
            ),
            Text(Point(60, 35), "Subsequent players that beat the previous player's score may raise the bet."),
            Text(Point(60, 30), "The first player with the best score wins the round."),
            Text(Point(60, 25), "In the event that no one makes a hand in a round, the ante is carried over."),
            Text(Point(60, 20), "Each player starts with 200 coins with which to ante and wager."),
        ]
        for i in range(13):
            rule2[i].draw(win)

    continuebutton = Button(win, Point(60, 10), 15, 7.5, "Continue")
    continuebutton.activate()

    pt = win.getMouse()
    while not continuebutton.clicked(pt):
        pt = win.getMouse()

    for i in range(13):
        rule2[i].undraw()
    continuebutton.destroy()
Ejemplo n.º 49
0
def main():
	
	win = GraphWin("Dice Roller")
	win.setCoords(0, 0, 10, 10)
	win.setBackground("green2")
	
	die1 = DieView(win, Point(3, 7), 2)
	die2 = DieView(win, Point(7, 7), 2)
	rollButton = Button(win, Point(5, 4.5), 6, 1, "Roll Dice")
	rollButton.activate()
	quitButton = Button(win, Point(5,1), 2, 1, "Quit")
	
	p = win.getMouse()
	while not quitButton.clickedab(p):
		if rollButton.clickedab(p):
			value1 = randrange(1, 7)
			die1.setValue(value1)
			value2 = randrange(1, 7)
			die2.setValue(value2)
			quitButton.activate()
		pt = win.getMouse()
			
	win.close()
Ejemplo n.º 50
0
def gettype(win):
    # Displays game choice for player
    # Returns the game type selected by player

    type = 0

    title1 = Text(Point(60, 55), "Slye's Dyce is a wagering dice game.")
    title1.draw(win)
    title2 = Text(Point(60, 45), "Would you like to play against the House or Others?")
    title2.draw(win)

    title3 = Text(Point(30, 20), "Vs. House Coming Soon")
    title3.draw(win)

    housebutton = Button(win, Point(30, 30), 15, 7.5, "House")
    # 	housebutton.activate()
    otherbutton = Button(win, Point(90, 30), 15, 7.5, "Others")
    otherbutton.activate()

    pt = win.getMouse()
    while not housebutton.clicked(pt) or not otherbutton.clicked(pt):
        if housebutton.clicked(pt):
            housebutton.destroy()
            otherbutton.destroy()
            title1.undraw()
            title2.undraw()
            title3.undraw()
            return 0
        if otherbutton.clicked(pt):
            housebutton.destroy()
            otherbutton.destroy()
            title1.undraw()
            title2.undraw()
            title3.undraw()
            return 1
        pt = win.getMouse()
Ejemplo n.º 51
0
    def splash(self):
        splash = "tetrology - n. A version of Connect Four for the truly smooth."
        self.splashText = Text(Point(self.x*.5, self.y*.8), splash)
        self.splashText.setSize(20)
        self.splashText.setFill("yellow")
        self.splashText.draw(self.win)

        self.p1name = Text(Point(self.x*.2, self.y*.5), "Player 1 Name:")
        self.p1name.setFill("yellow")
        self.p1name.draw(self.win)

        self.p2name = Text(Point(self.x*.2, self.y*.4), "Player 2 Name:")
        self.p2name.setFill("yellow")
        self.p2name.draw(self.win)

        self.p1entry = Entry(Point(self.x*.5, self.y*.5), 15)
        self.p1entry.setText("Player 1")
        self.p1entry.draw(self.win)

        self.p2entry = Entry(Point(self.x*.5, self.y*.4), 15)
        self.p2entry.setText("Player 2")
        self.p2entry.draw(self.win)

        sButton = Button(self.win, Point(self.x*.5, self.y*.3), self.x*.2,
                         self.y*.05, "Start Game")
        sButton.activate()
        iButton = Button(self.win, Point(self.x*.5, self.y*.25), self.x*.2,
                         self.y*.05, "Info")
        iButton.activate()
        qButton = Button(self.win, Point(self.x*.5, self.y*.2), self.x*.2,
                         self.y*.05, "Quit")
        qButton.activate()
        while True:
            p = self.win.getMouse()
            p1name = self.p1entry.getText()
            p2name = self.p2entry.getText()
            if sButton.clicked(p):
                self.p1Name = self.p1entry.getText()
                self.p2Name = self.p2entry.getText()
                self.splashText.undraw()
                self.p1name.undraw()
                self.p2name.undraw()
                self.p1entry.undraw()
                self.p2entry.undraw()
                sButton.undraw()
                iButton.undraw()
                qButton.undraw()
                return "Play"
            elif iButton.clicked(p):
                iScreen = InfoScreen()
            elif qButton.clicked(p):
                return "Quit"
Ejemplo n.º 52
0
def main ():

    #Create graphics window
    win = GraphWin(400,400)
    win.setCoords(0.0,0.0,10.0,10.0)

    #Create Message
    message1 = Text(Point(5.0, 9.0),'Welcome to Three Button Monte')
    message1.draw(win)

    #Create buttons
    number1 = Button(win, Point(2.0,4.0),1.0,1.0,'Door 1')
    number1.activate()
    number2 = Button(win, Point(5.0,4.0),1.0, 1.0, 'Door 2')
    number2.activate()
    number3 = Button(win, Point(8.0,4.0),1.0, 1.0, 'Door 3')
    number3.activate()

    #Ask user to pick a door
    message2 = Text(Point(5.0,7.5),'One door has been chosen. Click on a door to guess it. ')
    message2.draw(win)
    doorpick = win.getMouse()

    #Report results
    x = pickadoor()
    if x == 1 and number1.clicked(doorpick) == True:
        message2.setText('You picked the correct door! ')
    elif x == 2 and number2.clicked(doorpick) == True:
        message2.setText('You picked the correct door! ')
    elif x == 3 and number3.clicked(doorpick) == True:
        message2.setText('You picked the correct door! ')
    else:
        message1.setText("You did not pick the correct door.")
        message2.setText("The correct door was: ")
        message3 = Text(Point(6.5, 7.5), x)
        message3.draw(win)

    #Quit program
    message4 = Text(Point(5.0, 1.0),'Click anywhere to close. ')
    message4.draw(win)
    win.getMouse()
    win.close()
Ejemplo n.º 53
0
def main():
    win = GraphWin("Dice Roller")
    win.setCoords(0, 0, 10, 10)
    win.setBackground("green")

    tic = Face(win, Point(5,5), 2)  #the window, middle, size of drawing
    
    eyesButt = Button(win, Point(3, 1), 2, 1, "Eyes")
    quitButt = Button(win, Point(5, 9), 2, 1, "Quit")
    talkButt = Button(win, Point(7, 1), 2, 1, "Talk")
    eyesButt.activate()
    quitButt.activate()
    talkButt.activate()

    pt = win.getMouse()
    while not quitButt.clicked(pt):
        if eyesButt.clicked(pt):
            tic.newSpot(win)
        if talkButt.clicked(pt):
            tic.moveMouth(win)
        pt = win.getMouse()

    win.close()
def main():
    win = GraphWin("My Face in the Morning")
    win.setCoords(0, 0, 10, 10)
    win.setBackground("green")

    tic = PythonLab(win, Point(5,5), 2)  #the window, middle, size of drawing
    
    talkButt = Button(win, Point(2, 2), 2, 1, "Talk")
    quitButt = Button(win, Point(5, 9), 2, 1, "Quit")
    eyesButt = Button(win, Point(8, 2), 2, 1, "Eyes")
    talkButt.activate()
    quitButt.activate()
    eyesButt.activate()

    pt = win.getMouse()
    while not quitButt.clicked(pt):
        if eyesButt.clicked(pt):
            tic.moveEyes(win)
##        if eyesButt.clicked(pt);
  #          tic.moveEyes(win)
        pt = win.getMouse()

    win.close()
Ejemplo n.º 55
0
def quitButton(wind):
    quitButton = Button(wind, Point(7, 1), 2, 2, "QUIT")
    quitButton.activate()
    pt = wind.getMouse()
    if quitButton.clicked(pt):
        wind.close()
Ejemplo n.º 56
0
def anteup(win, players, numplayers):
    playerante = [
        Text(Point(30, 45), players[0].getname()),
        Text(Point(40, 45), players[1].getname()),
        Text(Point(50, 45), players[2].getname()),
        Text(Point(60, 45), players[3].getname()),
        Text(Point(70, 45), players[4].getname()),
        Text(Point(80, 45), players[5].getname()),
    ]
    antebuttons = [
        Button(win, Point(30, 40), 7, 4, "Ante"),
        Button(win, Point(40, 40), 7, 4, "Ante"),
        Button(win, Point(50, 40), 7, 4, "Ante"),
        Button(win, Point(60, 40), 7, 4, "Ante"),
        Button(win, Point(70, 40), 7, 4, "Ante"),
        Button(win, Point(80, 40), 7, 4, "Ante"),
    ]

    continuebutton = Button(win, Point(60, 20), 15, 7.5, "Continue")

    anted = [False, False, False, False, False, False]
    ante = 0

    for i in range(numplayers):
        playerante[i].draw(win)
        antebuttons[i].activate()

    for i in range(len(antebuttons)):
        if not antebuttons[i].getactive():
            antebuttons[i].destroy()

    pt = win.getMouse()
    while not continuebutton.clicked(pt):
        if (
            antebuttons[0].getactive() == False
            and antebuttons[1].getactive() == False
            and antebuttons[2].getactive() == False
            and antebuttons[3].getactive() == False
            and antebuttons[4].getactive() == False
            and antebuttons[5].getactive() == False
        ):
            continuebutton.activate()
        if antebuttons[0].clicked(pt):
            players[0].update(-1)
            anted[0] = True
            ante = ante + 1
            antebuttons[0].deactivate()
        if antebuttons[1].clicked(pt):
            players[1].update(-1)
            anted[1] = True
            ante = ante + 1
            antebuttons[1].deactivate()
        if antebuttons[2].clicked(pt):
            players[2].update(-1)
            anted[2] = True
            ante = ante + 1
            antebuttons[2].deactivate()
        if antebuttons[3].clicked(pt):
            players[3].update(-1)
            anted[3] = True
            ante = ante + 1
            antebuttons[3].deactivate()
        if antebuttons[4].clicked(pt):
            players[4].update(-1)
            anted[4] = True
            ante = ante + 1
            antebuttons[4].deactivate()
        if antebuttons[5].clicked(pt):
            players[5].update(-1)
            anted[5] = True
            ante = ante + 1
            antebuttons[5].deactivate()
        pt = win.getMouse()

    for i in range(numplayers):
        playerante[i].undraw()
        antebuttons[i].destroy()
    continuebutton.destroy()
    return ante  # anted option for later iteration
def main():
    win=GraphWin("Basketball",1200,900)
    win.setCoords(1200,0,0,900)
    setBackground(win)  #set background
    setCircle(win)      #set circle
    setLine(win)        #set line
    rButton = Button(win,Point(900,850),140,60,"Restart")
    qButton = Button(win,Point(400,850),140,60,"Quit")
    rButton.activate()
    qButton.activate()
 
    ball0=Ball(win,300,500)
    ball0.draw()
    ball_list=[0,0,0,0]
    for j in range(4):
        ball_list[j] = Ball(win,100,(850-j*100))
        ball_list[j].draw()
    i=-1
    score=0 
    while True:
        q=win.getMouse()
        if qButton.clicked(q):
            break
        if rButton.clicked(q):
            ball0=Ball(win,300,500)
            ball0.draw()
            ball_list=[0,0,0,0]
            for j in range(4):
                ball_list[j] = Ball(win,100,(850-j*100))
                ball_list[j].draw()
                i=-1
                score=0
        
        x=float(q.getX())
        y=float(q.getY())
        if 300.0<x<500.0 and 500.0<y<700.0 and 0<((x-300)*(x-300)+(y-500)*(y-500))<=25600:
            w=(x-300)*(x-300)+(y-500)*(y-500)
            bsin=float(y-500)/sqrt(w)
            bcos=float(x-300)/sqrt(w)
            t=0
            if 14400<((x-300)*(x-300)+(y-500)*(y-500))<=25600:
                v0=uniform(95,105)
            if 6400<((x-300)*(x-300)+(y-500)*(y-500))<=14400:
                v0=uniform(85,95)
            if 0<((x-300)*(x-300)+(y-500)*(y-500))<=6400:
                v0=uniform(75,85)
            if i==-1:
                while ball0.x<=1030 and ball0.y>=500:
                    t=t+1
                    a=300+v0*bcos*t
                    b=500+v0*bsin*t-5.0*t*t
                    ball0.f.move(v0*bcos*1,(v0*bsin-10.0*t+5.0))
                    ball0.x=a
                    ball0.y=b
                    sleep(0.1)
                if 1020<a<1100 and 500<b<650:
                    score=score+3
                    effect1(win)
                else:
                    score=score+0
                    effect2(win)
                ball0.undraw()
                i=i+1
                ball_list[i].move2Ball(300,500)
                continue
            if i>=0 and i<=3:
                a=ball_list[i].x
                b=ball_list[i].y
                while a<=1030 and b>=500:
                    t=t+1
                    a=300+v0*bcos*t
                    b=500+v0*bsin*t-5.0*t*t
                    ball_list[i].f.move(v0*bcos*1,(v0*bsin-10.0*t+5.0))
                    sleep(0.1)
                if 1020<a<1100 and 500<b<650:
                    score=score+3
                    effect1(win)
                else:
                    score=score+0
                    effect2(win)
                ball_list[i].undraw()
                if i<3:
                    i=i+1
                    ball_list[i].move2Ball(300,500)
                    continue
                else:
                    q=Text(Point(600,600),"Your final score is %-4d"%(score))
                    q.setFill("white")
                    q.setSize(35)
                    q.draw(win)
                    sleep(1.5)
                    q.undraw()
                    print "your final score is",score
                    continue
                
            
    win.close()
Ejemplo n.º 58
0
def weSeeCards():
    win = GraphWin("Bridge Hand",900,600)
    win.setBackground("gold")
    
    mess = Text(Point(445,70),"Welcome to the Bridge game. This game deals 4 hands and, neatly displays them along with\nthe associated point totals and indicates whether the hand is or not biddable."
                "The dealing of\nhands is done either at random or from a deck supplied as an input file. So you need to choose\nwhether to use a random deck or one constructed from a file. For a random deck, click on\nthe 'Random deck button', to construct from a file, click on the 'From file button'\nand to terminate the game click on the 'Quit button'.")
    mess.setTextColor("blue")
    mess.setFace("helvetica")
    mess.setSize(12)
    mess.setStyle("bold italic")
    
    mess.draw(win)

    quitbutton = Button(win,Point(750,170),55,20,"Quit")
    quitbutton.activate()
    fromfilebutton = Button(win,Point(300,170),85,20,"From file")
    fromfilebutton.activate()
    randomdeckbutton = Button(win,Point(150,170),115,20,"Random deck")
    randomdeckbutton.activate()
    runbutton = Button(win,Point(450,170),50,20,"Run")
    runbutton.activate()
    
    pt = win.getMouse()
    
    while True:
        
        if quitbutton.clicked(pt):
            win.close()
        
        elif fromfilebutton.clicked(pt):
            randomdeckbutton.deactivate()
            mess.setText("Enter the file name you want to construct the deck from (in the entry box below the 'From file button'),\nand click on the 'Run button' to print out the hands, their associated point totals and bidding status of each hand.\nClick on the 'Quit button' to terminate game.")
            output = Entry(Point(300,200),10)
            output.setFill("grey")
            output.draw(win)
            
            win.getMouse()
            filename = output.getText()
            if runbutton.clicked(pt):
                output.undraw()
            d = Deck(filename)
            d.shuffle()
            output.undraw()
            runbutton.deactivate()
            fromfilebutton.deactivate()
            
                
                
        elif randomdeckbutton.clicked(pt):
            fromfilebutton.deactivate()
            runbutton.deactivate()
            d = Deck()
            d.shuffle()
            
        handsStr = "\nNorth \nEast \nSouth \nWest"
        '''\nNorth \nEast \nSouth \nWest'''

        n,e,s,w = handsStr.split()
        n = Hand(n)
        e = Hand(e)
        s = Hand(s)
        w = Hand(w)
        
        for i in range(13):
            n.add(d.deal())
            e.add(d.deal())                
            s.add(d.deal())
            w.add(d.deal())
        
        hands = [n,e,s,w]
        mess.setText("Below are the hands you created along with their associated point totals,\nand the statements of whether a hand has an 'opening bid'\nClick on the 'Quit button' to terminate game.")
        
        y = 250
        
        for h in hands:
            h.sort()
            h.dump()
            showhand(h,y,win)
            for st in Card.SUITS:
                if (h.handPoints() >= 13 and
                    (h.countSuit(st) >= 5 or
                     (h.countSuit(st) == 4 and h.hasHonor(st)))):
                    Text(Point(600,y),h.label+" hand has "+str(h.handPoints())+" points, and is biddable").draw(win)
                    break
            else:
                Text(Point(600,y),h.label+" hand has "+str(h.handPoints())+" points, and is unbiddable").draw(win)
            y += 100    
           
        win.getMouse()
        win.close()
Ejemplo n.º 59
0
def main ():

    #Create window and Entry objects
    win = GraphWin('Data Sorting',400,200)
    inputText = Text(Point(95,40),"Enter the name of the data file")
    inputText.draw(win)
    inputFileName = Entry(Point(280,40),30)
    inputFileName.draw(win)
    outputText = Text(Point(95,70),"Enter the name of the output file")
    outputText.draw(win)
    outputFileName = Entry(Point(280,70),30)
    outputFileName.draw(win)

    # Introduction
    messageText = Text(Point(200,10),"This program sorts student data from one file and outputs it to another file.")
    messageText.draw(win)

    # Create buttons
    GPAsort = Button(win, Point(60,130),80,20,"Sort by GPA")
    Namesort = Button(win,Point(180, 130),80,20,"Sort by Name")
    Creditssort = Button(win,Point(300,130),80,20,"Sort by Credits")
    ascendingButton = Button(win, Point(120, 160),100, 20, "Ascending Order")
    descendingButton = Button(win, Point(260,160),100,20, "Descending Order")
    quitButton = Button(win,Point(370,180),50,20, "Quit")
    enterButton = Button(win,Point(300,100),120,20, "Submit file info")
    sortButton = Button(win,Point(100,100),80,20, "Sort Data")

    # while user has not chosen to quit the program
    enterButton.activate()
    p = win.getMouse()
    while not quitButton.clicked(p):

    # obtain data to sort and file to output to
        filename = inputFileName.getText()
        data = readStudents (filename)
        filename2 = outputFileName.getText()
        enterButton.deactivate()
        quitButton.deactivate()

    # User chooses a sorting method
        messageText.setText("Please click a button to sort by either GPA, name, or credit hours.")
        GPAsort.activate()
        Namesort.activate()
        Creditssort.activate()
        p = win.getMouse()
        if GPAsort.clicked(p):
            key = Student.gpa
        elif Namesort.clicked(p):
            key = Student.getName
        else:
            key = Student.getHours
        GPAsort.deactivate()
        Namesort.deactivate()
        Creditssort.deactivate()

    # User chooses to sort by ascending or descending order
        messageText.setText("Please click a button to choose to sort in ascending or descending order.")
        ascendingButton.activate()
        descendingButton.activate()
        p = win.getMouse()
        if descendingButton.clicked(p):
            reverse = True
        else:
            reverse = False
        ascendingButton.deactivate()
        descendingButton.deactivate()

    # Sort data and output to file
        messageText.setText("Click the sort button to sort the data.")
        sortButton.activate()
        win.getMouse()
        data.sort(key = key, reverse = reverse)
        writeStudents(data, filename2)
        sortButton.deactivate()

    #Allow user to enter another file
        enterButton.activate()
        quitButton.activate()
        messageText.setText("Enter another file or click quit to exit. ")
        p=win.getMouse()

    # Close window
    win.close()