def __init__(self):
        EasyFrame.__init__(self, title="Investment Calculator")

        #labels for the window
        self.addLabel(text="Initial amount", row=0, column=0)
        self.addLabel(text="Number of years", row=1, column=0)
        self.addLabel(text="Interest rate in %", row=2, column=0)

        #entry fields for inputs
        self.amount = self.addFloatField(value=0.0, row=0, column=1)
        self.period = self.addIntegerField(value=0, row=1, column=1)
        self.rate = self.addIntegerField(value=0, row=2, column=1)

        #button widget
        self.compute = self.addButton(text="Compute",
                                      row=3,
                                      column=0,
                                      columnspan=2,
                                      command=self.compute)

        #text-area widget
        self.outputArea = self.addTextArea("",
                                           row=4,
                                           column=0,
                                           columnspan=2,
                                           width=50,
                                           height=15)
Example #2
0
    def __init__(self):
        """Sets up the window and the widgets."""
        EasyFrame.__init__(self, title="Tax Calculator")

        # Label and field for the income
        self.addLabel(text="Income", row=0, column=0)
        self.incomeField = self.addFloatField(value=0.0, row=0, column=1)

        # Label and field for the number of dependents
        self.addLabel(text="Dependents", row=1, column=0)
        self.depField = self.addIntegerField(value=0, row=1, column=1)

        # Label and field for the exemption amount
        self.addLabel(text="Exemption amount", row=2, column=0)
        self.exeField = self.addFloatField(value=0.0, row=2, column=1)
        # The command button
        self.addButton(text="Compute",
                       row=3,
                       column=0,
                       columnspan=2,
                       command=self.computeTax)

        # Label and field for the tax
        self.addLabel(text="Total tax", row=4, column=0)
        self.taxField = self.addFloatField(value=0.0,
                                           row=4,
                                           column=1,
                                           precision=2)
Example #3
0
    def __init__(self):
        """Sets up a window and its widgets."""
        EasyFrame.__init__(self, title="Color Chooser Demo")

        # Labels and output fields
        self.addLabel('R', row=0, column=0)
        self.addLabel('G', row=1, column=0)
        self.addLabel('B', row=2, column=0)
        self.addLabel("Color", row=3, column=0)
        self.r = self.addIntegerField(value=0, row=0, column=1)
        self.g = self.addIntegerField(value=0, row=1, column=1)
        self.b = self.addIntegerField(value=0, row=2, column=1)
        self.hex = self.addTextField(text="#000000", row=3, column=1, width=10)

        # Canvas with an initial black background
        self.canvas = self.addCanvas(row=0,
                                     column=2,
                                     rowspan=4,
                                     width=50,
                                     background="#000000")

        # Command button
        self.addButton(text="Choose color",
                       row=4,
                       column=0,
                       columnspan=3,
                       command=self.chooseColor)
Example #4
0
    def __init__(self, model):
        """Sets up the view.  The model comes in as an argument."""
        EasyFrame.__init__(self, title = "Temperature Converter")
        self.model = model

        # Label and field for Celsius
        self.addLabel(text = "Celsius", row = 0, column = 0)
        self.celsiusField = self.addFloatField(value = 
                                               model.getCelsius(),
                                               row = 1,
                                               column = 0,
                                               precision = 2)

        # Label and field for Fahrenheit
        self.addLabel(text = "Fahrenheit", row = 0, column = 1)
        self.fahrField = self.addFloatField(value =
                                            model.getFahrenheit(),
                                            row = 1,
                                            column = 1,
                                            precision = 2)

        # Celsius to Fahrenheit button
        self.addButton(text = ">>>>",
                       row = 2, column = 0,
                       command = self.computeFahr)
        # Fahrenheit to Celsius button
        self.addButton(text = "<<<<",
                       row = 2, column = 1,
                       command = self.computeCelsius)
Example #5
0
    def __init__(self, title, n=10, side=50):
        EasyFrame.__init__(self, title=title)

        # Create a string of column indicators, e.g., 'ABCDEFGHIJ' (n=10)
        ord_a = 65  # Character 'A' ASCII code
        columns = ''.join([chr(x) for x in range(ord_a, ord_a + n)])

        # Initialise the data structure for all cells (nxn)
        cells = {x: [None] * n for x in columns}

        self.__cells = cells

        # Just the labels for the columns
        for col in columns:
            col_n = ord(col) - ord_a
            grid_cell = GridCell(self, side, side, outline='white')
            c = self.addCanvas(grid_cell, column=col_n+1, row=0)
            c.drawText(col, side//2, side//2, font=("Arial", 18, 'bold'))

        # Just the labels for the rows
        for row in range(1, n+1):
            grid_cell = GridCell(self, side, side, outline='white')
            c = self.addCanvas(grid_cell, column=0, row=row)
            c.drawText(str(row), side//2, side//2, font=("Arial", 18, 'bold'))

        # Initialise the grid -> the data structure is a dictionary.
        # The keys are 'A' .. 'J' (default) and the values are simply
        # lists indexed with the row number 0.. 9 (default).
        for col in columns:
            for row in range(n):
                col_n = ord(col) - ord_a
                grid_cell = GridCell(self, side, side, col, row)
                grid_cell.set_click_handler(self.on_click)
                cell = self.addCanvas(grid_cell, column=col_n+1, row=row+1)
                cells[col][row] = cell
    def __init__(self):
        """Initialize the window and widgets."""
        EasyFrame.__init__(self, title="Doctor", background=DoctorClient.COLOR)

        self.name = ''

        # Add the labels, fields, and button
        self.drLabel = self.addLabel(text="Want to connect?",
                                     row=0,
                                     column=0,
                                     columnspan=2,
                                     background=DoctorClient.COLOR)
        self.ptField = self.addTextField(text="",
                                         row=1,
                                         column=0,
                                         columnspan=2,
                                         width=50,
                                         state='disabled')
        self.sendBtn = self.addButton(row=2,
                                      column=0,
                                      text="Send reply",
                                      command=self.sendReply,
                                      state="disabled")
        self.connectBtn = self.addButton(row=2,
                                         column=1,
                                         text="Connect",
                                         command=self.connect)

        # Support the return key in the input field
        self.ptField.bind("<Return>", lambda event: self.sendReply())
Example #7
0
    def __init__(self):
        """Set up the window and widgets."""
        EasyFrame.__init__(self, title="Tidbit Loan Scheduler")
        """Input fields"""
        # self.addLabel()
        # self.priceField()
        self.addLabel(text="Purchase Price", row=0, column=0)
        self.priceField = self.addFloatField(value=0.0, row=0, column=1)

        # self.addLabel()
        # self.rateField()
        self.addLabel(text="Annual Interest Rate", row=1, column=0)
        self.rateField = self.addFloatField(value=0.0, row=1, column=1)
        """Command button"""
        self.button = self.addButton(text="Compute",
                                     row=2,
                                     column=0,
                                     columnspan=2,
                                     command=self.computeSchedule)
        """Output text box"""
        # self.outputArea()
        self.outputArea = self.addTextArea("",
                                           row=4,
                                           column=0,
                                           columnspan=2,
                                           width=5,
                                           height=15)
Example #8
0
 def __init__(self):
     EasyFrame.__init__(self, title="Bouncy")
     self.addLabel(text="Initial Height", row=0, column=0)
     self.heightField = self.addIntegerField(value=0,
                                             row=0,
                                             column=1,
                                             width=10)
     self.addLabel(text="Index", row=1, column=0)
     self.indexField = self.addFloatField(value=0,
                                          row=1,
                                          column=1,
                                          width=10)
     self.addLabel(text="Number of Bounces", row=2, column=0)
     self.bouncesField = self.addIntegerField(value=0,
                                              row=2,
                                              column=1,
                                              width=10)
     self.compuuteButton = self.addButton(text="Compute",
                                          row=3,
                                          column=0,
                                          columnspan=2,
                                          command=self.computeDistance)
     self.addLabel(text="Distance", row=4, column=0)
     self.distanceField = self.addFloatField(value=0,
                                             row=4,
                                             column=1,
                                             width=10)
Example #9
0
 def __init__(self):
     # sets up the window, labels, and buttons
     EasyFrame.__init__(self, title="Image Viewer")
     self.addLabel(text="Image Viewer 1.0",
                   row=0,
                   column=0,
                   columnspan=3,
                   sticky="NSEW")
     # creates button and label where the first image will be inserted
     self.label1 = self.addLabel(text="", row=1, column=0, sticky="NSEW")
     self.button1 = self.addButton(text="Click",
                                   row=2,
                                   column=0,
                                   command=self.change)
     # creates button and label where the second image will be inserted
     self.label2 = self.addLabel(text="", row=1, column=1, sticky="NSEW")
     self.button2 = self.addButton(text="Click",
                                   row=2,
                                   column=1,
                                   command=self.change2)
     # creates button and label where the third image will be inserted
     self.label3 = self.addLabel(text="", row=1, column=2, sticky="NSEW")
     self.button3 = self.addButton(text="Click",
                                   row=2,
                                   column=2,
                                   command=self.change3)
    def __init__(self):
        EasyFrame.__init__(self)
        EasyFrame.setTitle(self, "BouncyGUI")

        # Labels
        self.addLabel(text="Height", row=0, column=0)
        self.addLabel(text="Bounciness Index", row=1, column=0)
        self.addLabel(text="Num Of Bounces", row=2, column=0)

        # Fields
        self.heightFld = self.addFloatField(row=0, column=2, value=0, width=10)
        self.bouncyIndexFld = self.addFloatField(row=1,
                                                 column=2,
                                                 value=0,
                                                 width=10)
        self.numOfBouncesFld = self.addIntegerField(row=2,
                                                    column=2,
                                                    value=0,
                                                    width=10)

        # Output field
        self.totalDistanceFld = self.addTextField(row=4,
                                                  column=1,
                                                  width=17,
                                                  text="")

        # Buttons
        self.calcBtn = self.addButton(text="Calculate Distance",
                                      row=3,
                                      column=1,
                                      command=self.calculateDistance)
Example #11
0
 def __init__(self):
     """Sets up the window and the labels."""
     EasyFrame.__init__(self)
     self.addLabel(text = "(0, 0)", row = 0, column = 0, sticky = "NSEW")
     self.addLabel(text = "(0, 1)", row = 0, column = 1, sticky = "NSEW")
     self.addLabel(text = "(1, 0)", row = 1, column = 0, sticky = "NSEW")
     self.addLabel(text = "(1, 1)", row = 1, column = 1, sticky = "NSEW")
Example #12
0
    def __init__(self):
        """Sets up the window and the widgets."""
        EasyFrame.__init__(self, title = "List Box Demo",
                           width = 300, height = 150)

        # Set up the list box
        self.listBox = self.addListbox(row = 0, column = 0, rowspan = 4,
                                       listItemSelected = self.listItemSelected)

        # Add some items to the list box and select the first one
        self.listBox.insert(END, "Apple")
        self.listBox.insert(END, "Banana")
        self.listBox.insert(END, "Cherry")
        self.listBox.insert(END, "Orange")
        self.listBox.setSelectedIndex(0)

        # Set up the labels, fields, and buttons
        self.addLabel(text = "Input", row = 0, column = 1)
        self.addLabel(text = "Index", row = 1, column = 1)
        self.addLabel(text = "Current item", row = 2, column = 1)
        self.inputField = self.addTextField(text = "", row = 0,
                                            column = 2, width = 10)
        self.indexField = self.addIntegerField(value = "", row = 1,
                                               column = 2, width = 10)
        self.itemField = self.addTextField(text = "", row = 2,
                                           column = 2, width = 10)
        self.addButton(text = "Add", row = 3,
                       column = 1, command = self.add)
        self.removeButton = self.addButton(text = "Remove", row = 3,
                                           column = 2, command = self.remove)

        # Display current index and currently selected item
        self.listItemSelected(0)
 def __init__(self):
     """Initialize the window."""
     EasyFrame.__init__(self, title = "Chat Room")
     # Create and add the widgets to the window."""
     self.outputLabel = self.addLabel(text = "Transcript of the chat:",
                                     row = 0, column = 0,
                                     columnspan = 2,
                                     sticky = "NSEW")
     self.outputArea = self.addTextArea("", row = 1, column = 0,
                                        columnspan = 2,
                                        width = 50, height = 4)
     self.inputLabel = self.addLabel(text = "Want to connect?",
                                     row = 2, column = 0,
                                     columnspan = 2,
                                     sticky = "NSEW")
     self.inputArea = self.addTextArea("", row = 3, column = 0,
                                        columnspan = 2,
                                        width = 50, height = 4)
     self.sendButton = self.addButton(text = "Send",
                                      row = 4, column = 0,
                                      command = self.send,
                                      state = "disabled")
     self.connectButton = self.addButton(text = "Connect",
                                         row = 4, column = 1,
                                         command = self.connect)
Example #14
0
    def __init__(self):

        # Create the main window
        EasyFrame.__init__(self, "Tax Calculator")

        # Create labels & fields
        self.addLabel(text = "Gross Income", row = 0, column = 0)
        self.income = self.addFloatField(value = 0.0, row = 0, column = 1, columnspan = 2)

        self.addLabel(text = "Dependents", row = 1, column = 0)
        self.depend = self.addIntegerField(value = 0, row = 1, column = 2)

        self.addLabel(text = "Total tax", row = 5, column = 0)
        self.total = self.addFloatField(value = 0.0, row = 5, column = 1, columnspan = 2)

        # Create the radio button group
        self.addLabel(text = "Filing Status", row = 2, column = 0, columnspan = 3)
        self.filingStatus = self.addRadiobuttonGroup(row = 3, column = 0, columnspan = 3, orient = "horizontal")
        defaultRB = self.filingStatus.addRadiobutton(text = "Single: 20%")
        self.filingStatus.setSelectedButton(defaultRB)
        self.filingStatus.addRadiobutton(text = "Married: 15%")
        self.filingStatus.addRadiobutton(text = "Divorced: 10%")

        # Create a button to compute the tax
        self.compute = self.addButton(text = "Compute", row = 4, column = 1, command = self.compute)
Example #15
0
    def __init__(self):
        """Sets up the window and the widgeta."""
        EasyFrame.__init__(self, title="Radio Button Demo")

        # Add the label, button group and radio buttons for meats
        self.addLabel(text="Meat", row=0, column=0)
        self.meatGroup = self.addRadiobuttonGroup(row=1, column=0, rowspan=2)
        defaultRB = self.meatGroup.addRadiobutton(text="Chicken")
        # Make the chicken radio button the pre-selected option
        self.meatGroup.setSelectedButton(defaultRB)
        self.meatGroup.addRadiobutton(text="Beef")

        # Add the label, button group and radio buttons for potatoes
        self.addLabel(text="Potatoes", row=0, column=1)
        self.taterGroup = self.addRadiobuttonGroup(row=1, column=1, rowspan=2)
        defaultRB = self.taterGroup.addRadiobutton(text="French Fries")
        # Make the chicken radio button the pre-selected option
        self.taterGroup.setSelectedButton(defaultRB)
        self.taterGroup.addRadiobutton(text="Baked Potato")

        # Add the label, button group and radio buttons for veggies
        self.addLabel(text="Vegetable", row=0, column=2)
        self.vegGroup = self.addRadiobuttonGroup(row=1, column=2, rowspan=2)
        defaultRB = self.vegGroup.addRadiobutton(text="Applesauce")
        # Make the applesauce radio button the pre-selected option
        self.vegGroup.setSelectedButton(defaultRB)
        self.vegGroup.addRadiobutton(text="Green Beans")

        # Add the command button
        self.addButton(text="Place Order",
                       row=3,
                       column=0,
                       columnspan=3,
                       command=self.placeOrder)
Example #16
0
File: CH8P4.py Project: ozmaws/CH8
 def __init__(self):
     EasyFrame.__init__(self, title="Tempature Conversion")
     self.addLabel(text="Fahrenheit", row=0, column=0)
     self.fahrenheit = self.addFloatField(value=32.00,
                                          row=1,
                                          column=0,
                                          width=15,
                                          precision=2)
     self.addLabel(text="Celsius", row=0, column=1)
     self.celsius = self.addFloatField(value=0.00,
                                       row=1,
                                       column=1,
                                       width=15,
                                       precision=2)
     self.fahrenheit.bind('<Return>', lambda event: self.FtoC())
     self.celsius.bind('<Return>', lambda event: self.CtoF())
     self.addButton(text=">>>>",
                    row=2,
                    column=0,
                    columnspan=1,
                    command=self.FtoC)
     self.addButton(text="<<<<",
                    row=2,
                    column=1,
                    columnspan=2,
                    command=self.CtoF)
Example #17
0
 def __init__(self):
     """Sets up the window and widgets."""
     EasyFrame.__init__(self, "Market Simulator")
     self.addLabel(text = "Total running time",
                   row = 0, column = 0)
     self.addLabel(text = "Average processing time per customer",
                   row = 1, column = 0)
     self.addLabel(text = "Probablity of new arrival",
                   row = 2, column = 0)
     self.addLabel(text = "Number of cashiers",
                   row = 3, column = 0)
     self.addLabel(text = "Results",
                   row = 5, column = 0, columnspan = 2, sticky = "NSEW")
     self.runTimeFld = self.addIntegerField(value = 0, width = 5,
                                            row = 0, column = 1)
     self.aveTimeFld = self.addIntegerField(value = 0, width = 5,
                                            row = 1, column = 1)
     self.probabilityFld = self.addFloatField(value = 0.0, width = 5,
                                              row = 2, column = 1)
     self.cashiersFld = self.addIntegerField(value = 0, width = 5,
                                             row = 3, column = 1)
     self.outputArea = self.addTextArea("", row = 6, column = 0,
                                        columnspan = 2,
                                        width = 40, height = 10)
     self.runBtn = self.addButton(text = "Run", row = 4, column = 0,
                                  columnspan = 2,
                                  command = self.run)
 def __init__(self):
     """Sets up the calculator app."""
     
     EasyFrame.__init__(self, "Calculator App", background = "black",
                        resizable = False)
     self.calculator = Calculator()
     self.operatorEntered = False
     self.mainLabel = self.addLabel ("0", row = 0, column = 0,
                                     columnspan = 4, sticky = "E",
                                     background = "black", foreground = "white")
     self.clearButton = self.addButton ("AC", row = 1, column = 0,
                                        command = self.clearLabel)
     self.signButton = self.addButton ("+/-", row = 1, column = 1,
                                       command = self.changeSign)
     self.percentButton = self.addButton ("%", row = 1, column = 2)
     self.divideButton = self.addButton ("/", row = 1, column = 3,
                                         command = self.makeOperatorCommand("/"))
     self.multiplyButton = self.addButton ("x", row = 2, column = 3,
                                           command = self.makeOperatorCommand("*"))
     self.subtractButton = self.addButton ("-", row = 3, column = 3,
                                           command = self.makeOperatorCommand("-"))
     self.additionButton = self.addButton ("+", row = 4, column = 3,
                                           command = self.makeOperatorCommand("+"))
     self.equalsButton = self.addButton ("=", row = 5, column = 3,
                                         command = self.makeOperatorCommand("="))
     self.decimalButton = self.addButton (".", row = 5, column = 2,
                                          command = self.addDecimal)
     self.zeroButton = self.addButton ("0", row = 5, column = 0,
                                       command = self.addZero)
     digit = 9
     for row in range (2,5):
         for column in range (0,3):
             numberButton = self.addButton(str(digit), row, column)
             numberButton["command"] = self.makeCommand(str(digit))
             digit -= 1
Example #19
0
    def __init__(self):
        """Sets up the window,widgets, and data."""
        EasyFrame.__init__(self, title="Address Book Server")
        # Sets attributes for and creates and labels a button to open files
        self.file_open_btn = self.addButton(text="Open",
                                            row=0,
                                            column=0,
                                            command=self.open_file)
        self.file_label = self.addLabel(text="Please open an address book.",
                                        row=0,
                                        column=1)
        # Default setting of server status
        self.server_running = False
        # List of the available status states for the server
        self.status_label_dict = {
            "running": "Server is running.",
            "not_running": "Server is not running.",
            "error": "An error occurred."
        }
        # Sets attributes for and creates and labels start button
        self.status_button = self.addButton(text="Start",
                                            row=1,
                                            column=0,
                                            command=self.toggle_server)
        self.status_label = self.addLabel(
            text=self.status_label_dict["not_running"],
            row=1,
            column=1,
            foreground="red")

        self.server = socket(AF_INET, SOCK_STREAM)
        self.addressbook = None
Example #20
0
 def __init__(self):
     """Sets up the window and the labels."""
     EasyFrame.__init__(self)
     self.addLabel(text="(0, 0)", row=0, column=0, sticky="NSEW")
     self.addLabel(text="(0, 1)", row=0, column=1, sticky="NSEW")
     self.addLabel(text="(1, 0)", row=1, column=0, sticky="NSEW")
     self.addLabel(text="(1, 1)", row=1, column=1, sticky="NSEW")
Example #21
0
 def __init__(self):
    """Creates the war game, and sets up the Images and labels
    for the two cards to be displayed, the state label,
    and the command button."""
    EasyFrame.__init__(self, title = "Let's play War!")
    self.setSize(350, 350)
    self.game = WarGame()
    self.game.deal()
    self.playerLabel1 = self.addLabel(row = 0, column = 0,
                                       text = "Player 1")
    self.playerLabel2 = self.addLabel(row = 0, column = 1,
                                       text = "Player 2")
    self.image1 = PhotoImage(file = Card.BACK_NAME)
    self.image2 = PhotoImage(file = Card.BACK_NAME)
    self.cardImageLabel1 = self.addLabel("", row = 1, column = 0)
    self.cardImageLabel1["image"] = self.image1
    self.cardImageLabel2 = self.addLabel("", row = 1, column = 1)
    self.cardImageLabel2["image"] = self.image2
    self.stateLabel = self.addLabel("", row = 2, column = 0,
                                    columnspan = 2)
    self.nextCardButton = self.addButton(row = 3, column = 0,
                                 text = "Next card",
                                  command = self.nextCard)
    self.newGameButton = self.addButton(row = 4, column = 0,
                                        text = "New Game",
                                        state = "disabled",
                                        command = self.newGame)
 def __init__(self):
     """Initialize the window."""
     EasyFrame.__init__(self, title="Chat Room")
     # Create and add the widgets to the window."""
     self.outputLabel = self.addLabel(text="People found: ",
                                      row=0,
                                      column=0,
                                      columnspan=2,
                                      sticky="NSEW")
     self.outputArea = self.addTextArea("",
                                        row=1,
                                        column=0,
                                        columnspan=2,
                                        width=50,
                                        height=4)
     self.inputLabel = self.addLabel(text="Who are you searching for?",
                                     row=2,
                                     column=0,
                                     columnspan=2,
                                     sticky="NSEW")
     self.inputArea = self.addTextArea("",
                                       row=3,
                                       column=0,
                                       columnspan=2,
                                       width=50,
                                       height=4)
     self.sendButton = self.addButton(text="Search",
                                      row=4,
                                      column=0,
                                      command=self.send,
                                      state="disabled")
     self.connectButton = self.addButton(text="Load Phonebook",
                                         row=4,
                                         column=1,
                                         command=self.load)
Example #23
0
    def __init__(self):
        """Creates the dice, and sets up the Images and labels
        for the two dice to be displayed, the state label,
        and the two command buttons."""
        EasyFrame.__init__(self, title = "Card Demo")
        self.setSize(220, 200)
        self.mainDeck = Deck()
        self.dealtCard = "b"

        self.cardPanel = self.addPanel(row = 0, column = 0)

        self.deckLabel1 = self.cardPanel.addLabel("", row = 0,
                                       column = 0,
                                       sticky = "NSEW")
        self.stateLabel = self.cardPanel.addLabel("", row = 1, column = 0,
                                        sticky = "NSEW",
                                        columnspan = 2)

        self.buttonPanel = self.addPanel(row = 1, column = 0)
        self.buttonPanel.addButton(row = 2, column = 0,
                       text = "Deal",
                       command = self.deal)
        self.buttonPanel.addButton(row = 2, column = 1,
                       text = "Shuffle",
                       command = self.shuffle)
        self.buttonPanel.addButton(row = 2, column = 2,
                       text = "New deck",
                       command = self.newDeck)

        self.refreshImages()
    def __init__(self):
        """Creates the cards and sets up the images and labels for two cards
to be displayed, the state label, and two command buttons. """
        EasyFrame.__init__(self, title="Card Game")
        self.setSize(220,200)

        #create cards/deck
        self.card1=Deck()
        self.card="b"
        
      
        

        #labels
        self.cardLabel1= self.addLabel("",row=0, column=0, sticky= "NSEW",columnspan=2)
        
        self.stateLabel = self.addLabel(self.card, row = 1, column = 0,
                                        sticky = "NSEW",
                                        columnspan = 2)
        
        self.addButton(row = 2, column = 0,
                       text = "Draw",
                       command = self.nextDraw)
        
        self.addButton(row = 2, column = 1,
                       text = "New game",
                       command = self.newGame)
        
        self.refreshImages()
Example #25
0
 def __init__(self):
     #App title
     EasyFrame.__init__(self, title="Lottery Number Generator")
     #5 text fields with no text inside
     self.outputField0 = self.addTextField(text="",
                                           row=0,
                                           column=0,
                                           state="readonly")
     self.outputField1 = self.addTextField(text="",
                                           row=0,
                                           column=1,
                                           state="readonly")
     self.outputField2 = self.addTextField(text="",
                                           row=0,
                                           column=2,
                                           state="readonly")
     self.outputField3 = self.addTextField(text="",
                                           row=0,
                                           column=3,
                                           state="readonly")
     self.outputField4 = self.addTextField(text="",
                                           row=0,
                                           column=4,
                                           state="readonly")
     #Button that will run the generate function
     self.addButton(text="Generate", row=1, column=0, command=self.generate)
Example #26
0
    def __init__(self):
        """Set up the window and widgets."""
        EasyFrame.__init__(self, title="Bouncy")
        """Define the following fields"""
        # self.heightField (number entry)
        self.addLabel(text="Initial height", row=0, column=0)
        self.heightField = self.addFloatField(value=0.0, row=0, column=1)

        # self.indexField (number entry)
        self.addLabel(text="Bounciness index", row=1, column=0)
        self.indexField = self.addFloatField(value=0.0, row=1, column=1)

        # self.bouncesField (number entry)
        self.addLabel(text="Number of bounces", row=2, column=0)
        self.bouncesField = self.addIntegerField(value=0, row=2, column=1)

        self.addButton(text="Compute",
                       row=3,
                       column=1,
                       command=self.computeDistance)

        # self.distanceField (result result)
        self.addLabel(text="Total distance", row=4, column=0)
        self.distanceField = self.addFloatField(value=0.0,
                                                row=4,
                                                column=1,
                                                state="readonly")
Example #27
0
    def __init__(self):
        """Sets up the window and widgets."""
        EasyFrame.__init__(self, title = "Sphere Attributes")

        # Label and field for the radius
        self.addLabel(text = "Radius",
                      row = 0, column = 0)
        self.radiusField = self.addFloatField(value = 0.0,
                                              row = 0,
                                              column = 1)

        # Label and field for the output
        self.outputLabel = self.addLabel(text = "Diameter",
                                         row = 1, column = 0)
        self.outputField = self.addFloatField(value = 0.0,
                                              row = 1,
                                              column = 1)

        # The command buttons
        self.addButton(text = "Diameter",
                              row = 2, column = 0,
                              command = self.computeDiameter)
        self.addButton(text = "Area",
                              row = 2, column = 1,
                              command = self.computeArea)
        self.addButton(text = "Volume",
                              row = 2, column = 2,
                              command = self.computeVolume)
Example #28
0
    def __init__(self):
        """Sets up the window and the widgets."""
        EasyFrame.__init__(self, title="Tax Calculator")

        # Label and field for the income
        # (self.incomeField)
        self.addLabel(text="Gross income", row=0, column=0)
        self.incomeField = self.addFloatField(value=0.0,
                                              precision=2,
                                              row=0,
                                              column=1)

        # Label and field for the number of dependents
        # (self.depField)
        self.addLabel(text="Dependents", row=1, column=0)
        self.depField = self.addIntegerField(value=0, row=1, column=1)

        # The command button
        self.addButton(text="Compute",
                       row=2,
                       column=0,
                       columnspan=2,
                       command=self.computeTax)

        # Label and field for the tax
        # (self.taxField)
        self.addLabel(text="Total tax", row=3, column=0)
        self.taxField = self.addFloatField(value=0.0,
                                           row=3,
                                           column=1,
                                           precision=2,
                                           state="readonly")
Example #29
0
    def __init__(self):
        """Sets up the window and the widgets."""
        EasyFrame.__init__(self, title="Tax Calculator")
        self.standardDeduction = 10000
        self.exemptionPerDependent = 3000
        self.taxRate = .2
        self.taxToDisplay = 0.0

        # Label and field for the income
        self.incomeField = self.addLabel(text="Gross income", row=0, column=0)
        self.incomeField = self.addFloatField(value="0.0", row=0, column=1)

        # Label and field for the number of dependents
        self.depFieldLabel = self.addLabel(text="Dependents", row=1, column=0)
        self.depField = self.addIntegerField(value="0.0", row=1, column=1)

        # The command button
        self.actionButton = self.addButton(text="Compute",
                                           command=self.computeTax,
                                           row=3,
                                           column=2)

        # Label and field for the tax
        self.taxFieldLabel = self.addLabel(text="Total tax", row=4, column=0)
        self.taxField = self.addFloatField(value=self.taxToDisplay,
                                           row=4,
                                           column=2)
Example #30
0
    def __init__(self, number, myPort, otherPort):
        """Sets up the window and widgets."""
        EasyFrame.__init__(self, title = "Message App " + str(number))

        # Label and field for the input
        self.addLabel(text = "Input",
                      row = 0, column = 0)
        self.inputField = self.addTextField(text = "",
                                            row = 0,
                                            column = 1)

        # Text area for the output
        self.outputArea = self.addTextArea(text = "",
                                           row = 1,
                                           column = 0,
                                           columnspan = 2,
                                           width = 50, height = 15)

        # The command button
        self.button = self.addButton(text = "Send",
                                     row = 2, column = 0,
                                     columnspan = 2,
                                     command = self.sendMessage)

        # Set up and start the message server for this window
        myAddress = ('localhost', myPort)
        self.otherAddress = ('localhost', otherPort)
        myServer = MessageServer(self, myAddress)
        myServer.start()
Example #31
0
 def __init__(self):
     """Sets up the window and widgets."""
     EasyFrame.__init__(self, "Menu Demo")
     
     # Add the menu bar for the two menus
     menuBar = self.addMenuBar(row = 0, column = 0, columnspan = 2)
     
     # Add the File menu
     fileMenu = menuBar.addMenu("File")
     
     # Add the command options for the File menu
     newMenuCommand = fileMenu.addMenuItem("New",  self.newSelected)
     openMenuCommand = fileMenu.addMenuItem("Open", self.openSelected)
     saveMenuCommand = fileMenu.addMenuItem("Save", self.saveSelected)
     
     # Add the Edit menu
     editMenu = menuBar.addMenu("Edit")
     
     # Add the command options for the Edit menu
     copyMenuCommand = editMenu.addMenuItem("Copy",  self.copySelected)
     cutMenuCommand = editMenu.addMenuItem("Cut",   self.cutSelected)
     pasteMenuCommand = editMenu.addMenuItem("Paste", self.pasteSelected)
     
     # Output field for the results
     self.output = self.addTextField("", row = 1, column = 0)
Example #32
0
    def __init__(self):
        '''Sets up the window and widgets'''
        EasyFrame.__init__(self, title="Investment Calculator")
        #Labels for the window
        self.addLabel(text="Initial Amount", row=0, column=0)
        self.addLabel(text="Number of Years", row=1, column=0)
        self.addLabel(text="Interest Rate in %", row=2, column=0)

        #Entry fields
        self.amount = self.addFloatField(value=0.0, row=0, column=1)
        self.period = self.addIntegerField(value=0, row=1, column=1)
        self.rate = self.addIntegerField(value=0, row=2, column=1)

        #Button
        self.compute = self.addButton(text="Compute",
                                      row=3,
                                      column=0,
                                      columnspan=2,
                                      command=self.compute)

        #Text area widget
        self.outputArea = self.addTextArea(text="",
                                           row=4,
                                           column=0,
                                           columnspan=2,
                                           width=50,
                                           height=15)
 def __init__(self):
     EasyFrame.__init__(self, title = "Block Cipher Encryption")
     self.setResizable(False)
     self.matrix = makeMatrix()
     self.matrixPanel = self.addPanel(row = 0, column = 0)
     self.addCanvases()
     fieldPanel = self.addPanel(row = 8, column = 0,
                                columnspan = 12,
                                background = "yellow")
     fieldPanel.addLabel(text = "Plaintext", row = 0, column = 0,
                         background = "yellow")
     self.plainField = fieldPanel.addTextField(text = "",
                                               row = 0,
                                               column = 1)
     fieldPanel.addLabel(text = "Ciphertext", row = 1, column = 0,
                         background = "yellow")
     self.cipherField = fieldPanel.addTextField("", row = 1,
                                                column = 1,
                                                state = "readonly")
     buttonPanel = self.addPanel(row = 9, column = 0,
                                 columnspan = 12,
                                 background = "black")
     self.encryptButton = buttonPanel.addButton(text = "Encrypt",
                                                row = 0, column = 0,
                                                command = self.encrypt)
     self.matrixButton = buttonPanel.addButton(text = "New matrix",
                                               row = 0,
                                               column = 1,
                                               command = self.newMatrix)
Example #34
0
 def __init__(self):
    """Creates the war game, and sets up the Images and labels
    for the two cards to be displayed, the state label,
    and the command button."""
    EasyFrame.__init__(self, title = "Let's play War!")
    self.setSize(300, 300)
    self.game = WarGame()
    self.game.deal()
    self.playerLabel1 = self.addLabel(row = 0, column = 0,
                                       text = "Player 1")
    self.playerLabel2 = self.addLabel(row = 0, column = 1,
                                       text = "Player 2")
    self.image1 = PhotoImage(file = Card.BACK_NAME)
    self.image2 = PhotoImage(file = Card.BACK_NAME)
    self.cardImageLabel1 = self.addLabel("", row = 1, column = 0)
    self.cardImageLabel1["image"] = self.image1
    self.cardImageLabel2 = self.addLabel("", row = 1, column = 1)
    self.cardImageLabel2["image"] = self.image2
    self.stateLabel = self.addLabel("", row = 2, column = 0,
                                    columnspan = 2)
    self.nextCardButton = self.addButton(row = 3, column = 0,
                                 text = "Next card",
                                 command = self.nextCard)
    self.newGameButton = self.addButton(row = 3, column = 1,
                                 text = "New Game",
                                 command = self.newGame,
                                  state = 'disabled')
    def __init__(self):

        EasyFrame.__init__(self, title="Fahrenheit/Celsius Converter")

        # Labels and Input fields
        self.addLabel(text="Fahrenheit", row=0, column=0, sticky="EW")
        self.addLabel(text="Celsius", row=0, column=1, sticky="EW")
        self.fahrenheit = self.addFloatField(value=32.0,
                                             row=1,
                                             column=0,
                                             precision=1)
        self.celsius = self.addFloatField(value=0,
                                          row=1,
                                          column=1,
                                          precision=1)

        # Buttons for activating conversions
        self.addButton(text=">>>>", row=2, column=0, command=self.calcCelsius)
        self.addButton(text="<<<<",
                       row=2,
                       column=1,
                       command=self.calcFahrenheit)

        # Bind keyboad events
        self.fahrenheit.bind("<Return>", lambda event: self.calcCelsius())
        self.celsius.bind("<Return>", lambda event: self.calcFahrenheit())
Example #36
0
 def __init__(self):
     """Initialize the frame and establish the data model."""
     EasyFrame.__init__(self, title="ATM")
     # Create and add the widgets to the window."""
     self.nameLabel = self.addLabel(row=0, column=0, text="Name")
     self.pinLabel = self.addLabel(row=1, column=0, text="PIN")
     self.amountLabel = self.addLabel(row=2, column=0, text="Amount")
     self.statusLabel = self.addLabel(row=3, column=0, text="Status")
     self.nameField = self.addTextField(row=0, column=1, text="")
     self.pinField = self.addTextField(row=1, column=1, text="")
     self.amountField = self.addFloatField(row=2, column=1, value=0.0)
     self.statusField = self.addTextField(row=3,
                                          column=1,
                                          text="Welcome to the Bank!")
     self.balanceButton = self.addButton(row=0,
                                         column=2,
                                         text="Balance",
                                         command=Handler.getBalance,
                                         state="disabled")
     self.depositButton = self.addButton(row=1,
                                         column=2,
                                         text="Deposit",
                                         command=Handler.deposit,
                                         state="disabled")
     self.withdrawButton = self.addButton(row=2,
                                          column=2,
                                          text="Withdraw",
                                          command=Handler.withdraw,
                                          state="disabled")
     self.loginButton = self.addButton(row=3,
                                       column=2,
                                       text="Login",
                                       command=Handler.login)
Example #37
0
 def __init__(self):
     EasyFrame.__init__(self,
                        title='Mod 4 Class Code',
                        width=650,
                        height=400,
                        background='blue')
     #a label is usually just text
     self.addLabel(text="(0,0)",
                   row=0,
                   column=0,
                   sticky='NSEW',
                   background='green')
     self.addLabel(text="(1,0)",
                   row=1,
                   column=0,
                   sticky='SEW',
                   background='aquamarine')
     self.addLabel(text="(0,1)",
                   row=0,
                   column=1,
                   sticky='N',
                   background='yellow')
     self.addLabel(text="(1,1)",
                   row=1,
                   column=1,
                   sticky='SE',
                   background='orange')
Example #38
0
 def __init__(self, model):
     """Sets up the window and widgets."""
     self.model = model
     EasyFrame.__init__(self, "ER Scheduler")
     self.addLabel(text = "Patient name",
                   row = 0, column = 0)
     self.nameFld = self.addTextField(text = "",
                                      row = 0, column = 1)
     self.conditionGrp = self.addRadiobuttonGroup(row = 1, column = 0)
     selectedBtn = self.conditionGrp.addRadiobutton("Fair condition")
     self.conditionGrp.addRadiobutton("Serious condition")
     self.conditionGrp.addRadiobutton("Critical condition")
     self.conditionGrp.setSelectedButton(selectedBtn)
     self.addButton(text = "Schedule patient", row = 1, column = 1,
                    rowspan = 3, command = self.schedule)
     self.addLabel(text = "Current activity", row = 4, column = 0,
                   columnspan = 2, sticky = "NSEW")
     self.outputArea = self.addTextArea("", row = 5, column = 0,
                                        columnspan = 2,
                                        width = 40, height = 10)
     self.treatNextBtn = self.addButton(text = "Treat next",
                                        row = 6, column = 0,
                                        command = self.treatNext,
                                        state = "disabled")
     self.treatAllBtn = self.addButton(text = "Treat all",
                                       row = 6, column = 1,
                                       command = self.treatAll,
                                       state = "disabled")
Example #39
0
    def __init__(self):
        """Sets up the window and the widgets."""
        EasyFrame.__init__(self, title = "Song Browser",
                           width = 300, height = 150)

        # Create a model
        self.database = SongDatabase()
        self.selectedTitle = None

        # Set up the menus
        menuBar = self.addMenuBar(row = 0, column = 0, columnspan = 2)
        fileMenu = menuBar.addMenu("File")
        fileMenu.addMenuItem("Open", self.openFile)
        fileMenu.addMenuItem("Save", self.saveFile)
        fileMenu.addMenuItem("Save As...", self.saveFileAs)
        
        self.editMenu = menuBar.addMenu("Edit", state = DISABLED)
        self.editMenu.addMenuItem("Find", self.findSong)
        self.editMenu.addMenuItem("Delete", self.deleteSong)

        # Set up the list box
        self.listBox = self.addListbox(row = 1, column = 0, width = 20,
                                       listItemSelected = self.listItemSelected)

        # Set the text area
        self.outputArea = self.addTextArea("", row = 1, column = 1,
                                           width = 30, height = 4)
Example #40
0
 def __init__(self):
     EasyFrame.__init__(self,
                        width=400,
                        height=200,
                        title="Grade converter",
                        background="pink")
     self.titletext = self.addLabel(
         text="This converts your scores to percentages",
         row=0,
         sticky="NSEW",
         column=0)
     mainPanel = self.addPanel(row=1, column=0, background="pink")
     self.direction1 = mainPanel.addLabel(
         text="points you got on the assignment", row=1, column=0)
     self.Input1 = mainPanel.addTextField("", row=1, column=2)
     self.direction2 = mainPanel.addLabel(
         text="total number of points for the assignment", row=2, column=0)
     self.Input2 = mainPanel.addTextField("", row=2, column=2)
     self.saveas = self.addButton("Save As",
                                  row=3,
                                  column=0,
                                  command=self.save_as)
     self.save = self.addButton("Save",
                                row=4,
                                column=0,
                                command=self.convert)
Example #41
0
    def __init__(self):
        """Sets up the window and widgets."""
        EasyFrame.__init__(self)

        # Label and field for the input
        self.addLabel(text = "An integer",
                      row = 0, column = 0)
        self.inputField = self.addIntegerField(value = 0,
                                               row = 0,
                                               column = 1,
                                               width = 10)

        # Label and field for the output
        self.addLabel(text = "Square root",
                      row = 1, column = 0)
        self.outputField = self.addFloatField(value = 0.0,
                                              row = 1,
                                              column = 1,
                                              width = 8,
                                              precision = 2,
                                              state = "readonly")

        # The command button
        self.addButton(text = "Compute", row = 2, column = 0,
                       columnspan = 2, command = self.computeSqrt)
Example #42
0
 def __init__(self):
     """Sets up the window and the labels."""
     EasyFrame.__init__(self, "NineCells")
     for x in range (0,3):
         for y in range (0,3):
             labelText = "(" + str(x) + "," + str(y) + ")"
             self.addLabel (text = labelText, row = y , column = x,
                            sticky = "NSEW")
Example #43
0
 def __init__(self, bank):
     """Initialize the frame and establish the data model."""
     EasyFrame.__init__(self, title = "Bank Management",
                        background = BankManager.COLOR)
     self.bank = bank
     self.accountPosition = None
     self.create_widgets()
     self.displayAccount()
Example #44
0
    def __init__(self):
        """Sets up the window and widgets."""
        EasyFrame.__init__(self, title = "Mouse Demo 2")

        # Canvas
        self.shapeCanvas = ShapeCanvas(self)
        self.addCanvas(self.shapeCanvas, row = 0, column = 0,
                       width = 300, height = 150)
Example #45
0
    def __init__(self):
        """Sets up the window and the label."""
        EasyFrame.__init__(self)
        textLabel = self.addLabel(text = "Hello world!", row = 0, column = 0,
                      sticky = "NSEW")

        # Set font and color of the caption.
        font = Font(family = "Verdana", size = 24, weight = "bold")
        textLabel["font"] = font
        textLabel["foreground"] = "red"
Example #46
0
    def __init__(self):
        """Sets up the window and widgets."""
        EasyFrame.__init__(self, title="Canvas Demo 1")
        self.colors = ("blue", "green", "red", "yellow")

        # Canvas
        self.canvas = self.addCanvas(row=0, column=0, width=300, height=150, background="gray")

        # Command button
        self.ovalButton = self.addButton(text="Draw oval", row=1, column=0, command=self.drawOval)
Example #47
0
 def __init__(self):
     """Sets up the window and widgets."""
     EasyFrame.__init__(self, "File Dialog Demo")
     self.outputArea = self.addTextArea("", row = 0, column = 0,
                                        columnspan = 2,
                                        width = 80, height = 15)
     self.addButton(text = "Open", row = 1, column = 0,
                    command = self.openFile)
     self.addButton(text = "Save As...", row = 1, column = 1,
                    command = self.saveFileAs)
Example #48
0
 def __init__(self):
     """Sets up the window, label, and buttons."""
     EasyFrame.__init__(self, "Calculator")
     self.digits = self.addLabel("", row = 0, column = 0,
                                 columnspan = 3, sticky = "NSEW")
     digit = 9
     for row in range(1, 4):
         for column in range(0, 3):
             button = self.addButton(str(digit), row, column)
             button["command"] = self.makeCommand(button)
             digit -= 1
Example #49
0
    def __init__(self, size = 8):
        """Sets up the window, label, and buttons."""
        EasyFrame.__init__(self, "Testing")
        self.square = ChessSquare(self, width = 70, height = 70,
                                  background = "white")
        self.addCanvas(canvas = self.square,
                       row = 0, column = 0, columnspan = 2)
        self.addButton(text = "Draw", row = 1, column = 0,
                       command = self.draw)

        self.addButton(text = "Erase", row = 1, column = 1,
                       command = self.erase)
Example #50
0
    def __init__(self):
        """Sets up the window and widgets."""
        EasyFrame.__init__(self, "Check Button Demo")
        
        # Add two check buttons
        self.firstCB = self.addCheckbutton(text = "First",
                                           row = 0, column = 0,
                                           command = self.first)

        self.secondCB = self.addCheckbutton(text = "Second",
                                            row = 1, column = 0,
                                            command = self.second)
 def __init__(self):
     """Initialize the frame and widgets."""
     EasyFrame.__init__(self, title = "Doctor Server",
                        background = DoctorServerGUI.COLOR)
     self.hostLabel = self.addLabel(row = 0, column = 0,
                                    text = "Host name")
     self.hostField = self.addTextField(row = 0, column = 1,
                                        text = gethostname())
     self.startButton = self.addButton(row = 1, column = 0,
                                       columnspan = 3,
                                       text = "Start server",
                                       command = self.startServer)
     self.statusArea = self.addTextField(row = 2, column = 0,
                                        columnspan = 3,
                                        text = "")
     self.hostLabel["background"] = DoctorServerGUI.COLOR
Example #52
0
 def __init__(self, model):
     """Sets up the window, label, and buttons."""
     EasyFrame.__init__(self, "An Amazin' Maze")
     self.model = model
     # Add maze squares to the grid
     self.squares = Grid(self.model.getHeight(), self.model.getWidth())
     for row in range(0, self.squares.getHeight()):
         for column in range(0, self.squares.getWidth()):
             square = MazeSquare(self, width = 20, height = 20,
                                letter =  self.model.getLetter(row, column))
             square = self.addCanvas(canvas = square,
                                     row = row, column = column)
             self.squares[row][column] = square
     self.moveButton = self.addButton(text = "Move",
                                      row = self.model.getHeight(),
                                      column = 0, columnspan = self.model.getWidth(),
                                      command = self.move)
Example #53
0
	def __init__(self):
		"""Sets up the window and widgets."""
		EasyFrame.__init__(self, title = "Image Demo")
		self.setResizable(False)
		self.imageLabel = self.addLabel(text = "",
					               row = 0, column = 0,
					               sticky = "NSEW")
		textLabel = self.addLabel(text = "Smokey the cat",
					              row = 1, column = 0,
					              sticky = "NSEW")
		

		#self.update_display()
		# Set the font and color of the caption.
		#font = Font(family = "Verdana", size = 20, slant = "italic")
		#textLabel["font"] = font
		textLabel["foreground"] = "blue"
Example #54
0
    def __init__(self):
        """Sets up the window and widgets."""
        EasyFrame.__init__(self, "Investment Calculator")
        self.addLabel(text = "Initial amount", row = 0, column = 0)
        self.addLabel(text = "Number of years", row = 1, column = 0)
        self.addLabel(text = "Interest rate in %", row = 2, column = 0)
        self.amount = self.addFloatField(value = 0.0, row = 0, column = 1)
        self.period = self.addIntegerField(value = 0, row = 1, column = 1)
        self.rate = self.addIntegerField(value = 0, row = 2, column = 1)

        self.outputArea = self.addTextArea("", row = 4, column = 0,
                                           columnspan = 2,
                                           width = 50, height = 15)

        self.compute = self.addButton(text = "Compute", row = 3, column = 0,
                                      columnspan = 2,
                                      command = self.compute)
Example #55
0
    def __init__(self):
        """Sets up the window, label, and buttons."""
        EasyFrame.__init__(self)

        # A single label in the first row.
        self.label = self.addLabel(text = "Hello world!",
                                   row = 0, column = 0,
                                   columnspan = 2, sticky = "NSEW")

        # Two command buttons in the second row.
        self.clearBtn = self.addButton(text = "Clear",
                                       row = 1, column = 0,
                                       command = self.clear)
        self.restoreBtn = self.addButton(text = "Restore",
                                         row = 1, column = 1,
                                         command = self.restore,
                                         state = "disabled")
        #self.newWindow = tk
        self.app = CircleArea(self.newWindow)
Example #56
0
    def __init__(self):
        """Sets up the window and widgets."""
        EasyFrame.__init__(self, title = "Mouse Demo 3")

        # Canvas
        self.shapeCanvas = ShapeCanvas(self)
        self.addCanvas(self.shapeCanvas, row = 0, column = 0,
                       columnspan = 2, width = 300, height = 150)
        
        # Radio buttons
        self.commandGroup = self.addRadiobuttonGroup(row = 1,
                                                     column = 0,
                                                     rowspan = 2,
                                                     orient = "horizontal")
        defaultRB = self.commandGroup.addRadiobutton(text = "Draw",
                                                     command = self.chooseCommand)
        self.commandGroup.setSelectedButton(defaultRB)
        self.commandGroup.addRadiobutton(text = "Erase",
                                         command = self.chooseCommand)
Example #57
0
    def __init__(self):
        """Sets up the window and widgets."""
        EasyFrame.__init__(self, title = "Image Demo")
        self.setResizable(False)
        imageLabel = self.addLabel(text = "",
                                   row = 0, column = 0,
                                   sticky = "NSEW")
        textLabel = self.addLabel(text = "Smokey the cat",
                                  row = 1, column = 0,
                                  sticky = "NSEW")
        
        # Load the image and associate it with the image label.
        self.image = PhotoImage(file = "smokey.gif")
        imageLabel["image"] = self.image

        # Set the font and color of the caption.
        font = Font(family = "Verdana", size = 20, slant = "italic")
        textLabel["font"] = font
        textLabel["foreground"] = "blue"
Example #58
0
 def __init__(self):
    EasyFrame.__init__(self, title = "Testing a Deck Display")
    self.setSize(350, 200)
    self.deck = Deck()
    self.card = self.deck.deal()
    self.image = PhotoImage(file = self.card.fileName)
    self.cardImageLabel = self.addLabel("", row = 0, column = 0)
    self.cardImageLabel["image"] = self.image
    self.cardNameLabel = self.addLabel(row = 1, column = 0,
                                       text = self.card)
    self.button = self.addButton(row = 0, column = 1,
                                 text = "Next Card",
                                 command = self.nextCard)
    self.button = self.addButton(row = 1, column = 1,
                                 text = "Shuffle",
                                 command = self.shuffleDeck)
    self.button = self.addButton(row = 2, column = 1,
                                 text = "New Deck",
                                 command = self.newDeck)
Example #59
0
    def __init__(self):
        """Sets up the window and widgets."""
        EasyFrame.__init__(self, "Radio Button Demo")

        # Add the button group
        self.group = self.addRadiobuttonGroup(row=0, column=0, rowspan=4)

        # Add the radio buttons to the group
        self.group.addRadiobutton("Freshman")
        self.group.addRadiobutton("Sophomore")
        self.group.addRadiobutton("Junior")
        defaultRB = self.group.addRadiobutton("Senior")

        # Select one of the buttons in the group
        self.group.setSelectedButton(defaultRB)

        # Output field and command button for the results
        self.output = self.addTextField("", row=0, column=1)
        self.addButton("Display", row=1, column=1, command=self.displayButton)