Exemple #1
0
    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()
Exemple #2
0
	def __createButtons(self):
		# create list of buttons
		# start with all the standard sized buttons
		# bSpecs gives center coords and label of buttons
		bSpecs = [ (2,1,'0'), (3,1,'.'),
					(1,2,'1'), (2,2,'2'), (3,2,'3'), (4,2,'+'), (5,2,'-'),
					(1,3,'4'), (2,3,'5'), (3,3,'6'), (4,3,'*'), (5,3,'/'),
					(1,4,'7'), (2,4,'8'), (3,4,'9'), (4,4,'<-'), (5,4,'C')]

		self.buttons = []
		for (cx, cy, label) in bSpecs:
			self.buttons.append(Button(self.win,Point(cx,cy),
												.75, .75, label))
		# create the larger '=' button
		self.buttons.append(Button(self.win, Point(4.5,1), 1.75, 1.00, "="))
		# activate all buttons
		for b in self.buttons:
			b.activate()
Exemple #3
0
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()
Exemple #4
0
 def __init__(self):
     self.ExitWin = GraphWin("Goodbye!", 600, 400)
     self.ExitWin.setBackground("blue")
     self.buttons = []
     bSpecs = [(150, 200, 'Make another transaction'), (450, 200, 'Exit')]
     for (cx, cy, label) in bSpecs:
         self.buttons.append(
             Button(self.ExitWin, Point(cx, cy), 175, 50, label))
     for b in self.buttons:
         b.activate()
    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()
Exemple #6
0
    def __init__(self):
        self.OptionsWin = GraphWin("BankName", 600, 400)
        self.OptionsWin.setBackground("blue")

        banner = Text(Point(290, 50), "Please select a transaction")
        banner.setSize(24)
        banner.setStyle("bold")
        banner.draw(self.OptionsWin)

        self.buttons = []
        bSpecs = [(175, 125, 'Check Balances'), (175, 225, 'Withdraw Cash'),
                  (175, 325, "Transfer Money")]
        for (cx, cy, label) in bSpecs:
            self.buttons.append(
                Button(self.OptionsWin, Point(cx, cy), 100, 50, label))
        for b in self.buttons:
            b.activate()
        self.buttons2 = []
        bSpecs2 = [(400, 160, 'From Checking'), (400, 310, 'From Savings')]
        for (cx, cy, label) in bSpecs2:
            self.buttons2.append(
                Button(self.OptionsWin, Point(cx, cy), 150, 75, label))
        for b in self.buttons2:
            b.activate()
Exemple #7
0
    def __init__(self):
        self.WithdrawWin = GraphWin("Withdrawal", 600, 400)
        self.WithdrawWin.setBackground("blue")
        self.buttons = []

        self.amountMsg = Text(Point(300, 50),
                              "How much would you like to withdraw?")
        self.amountMsg.setSize(24)
        self.amountMsg.draw(self.WithdrawWin)

        bSpecs = [(150, 150, '$20'), (150, 250, '$40'), (150, 350, '$60'),
                  (300, 150, '$80'), (300, 250, '$100'), (300, 350, '$200'),
                  (450, 150, '$500'), (450, 250, '$1,000')]
        for (cx, cy, label) in bSpecs:
            self.buttons.append(
                Button(self.WithdrawWin, Point(cx, cy), 100, 75, label))
        for b in self.buttons:
            b.activate()
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()
Exemple #9
0
    def __init__(self, balance):
        # Show balance
        self.BalancesWin = GraphWin("Balance", 600, 400)
        self.BalancesWin.setBackground("blue")
        self.balance = balance
        self.buttons = []
        self.balanceMsg = Text(Point(250, 80), "Your balance is: ")
        self.balanceMsg.setSize(24)
        self.balanceMsg.draw(self.BalancesWin)
        self.balance = Text(Point(400, 80), self.balance)
        self.balance.setSize(24)
        self.balance.draw(self.BalancesWin)

        # User chooses to exit or make another transaction
        bSpecs = [(150, 250, 'Make another transaction'), (450, 250, 'Exit')]
        for (cx, cy, label) in bSpecs:
            self.buttons.append(
                Button(self.BalancesWin, Point(cx, cy), 175, 50, label))
        for b in self.buttons:
            b.activate()
Exemple #10
0
    def __init__(self):
        self.TransferWin = GraphWin("Transfer Money", 600, 400)
        self.TransferWin.setBackground("blue")

        banner = Text(Point(300, 80), "Choose an Option Below: ")
        banner.setSize(32)
        banner.setStyle("bold")
        banner.draw(self.TransferWin)
        self.buttons = []

        bSpecs = [(200, 300, 'From checking to savings'),
                  (400, 300, 'From savings to checking')]
        for (cx, cy, label) in bSpecs:
            self.buttons.append(
                Button(self.TransferWin, Point(cx, cy), 175, 50, label))
        for b in self.buttons:
            b.activate()

        self.amountMsg = Text(Point(225, 200), "Amount: ")
        self.amountMsg.setSize(16)
        self.amountMsg.draw(self.TransferWin)
        self.input = Entry(Point(340, 200), 25)
        self.input.draw(self.TransferWin)
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)
    outfileName = Entry(Point(280, 70), 30)
    outfileName.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 dta to sort and file to output to
        filename = inputFileName.getText()
        data = readStudents(filename)
        filename2 = outfileName.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, filename)
        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()