assignment 10

1
Python Code from tkinter import * class App(Tk): def __init__(self): Tk.__init__(self) self.headerFont = ("Helvetica", "16", "bold italic") self.title("Assessor Software") self.addTaxes() self.addOutput() def addTaxes(self): Label(self, text = "Assessor Program", font = self.headerFont).grid(columnspan = 3) Label(self,justify=CENTER, text = "Enter Property Value").grid(row = 1, column = 0) self.txtProperty = Entry(self) self.txtProperty.grid(row = 1, column = 3) self.txtProperty.insert(0, "<enter value here>") def addOutput(self): self.btnCalc = Button(self, wraplength=120, text = "Calculate Assessment Value and Property Taxes") self.btnCalc.grid(row = 10, columnspan = 3) self.btnCalc["command"] = self.calculate Label(self, text = "Assessment Value").grid(row = 11, column = 0) self.lblAssessment = Label(self, bg = "#fff", anchor = "w", relief = "groove") self.lblAssessment.grid(row = 11, column = 3, sticky = "we") Label(self, text = "Property Tax").grid(row = 12, column = 0) self.lblTaxes = Label(self, bg = "#fff", anchor = "w", relief = "groove") self.lblTaxes.grid(row = 12, column = 3, sticky = "we") def calculate(self): taxes = int(self.txtProperty.get()) #get assessment assessment = taxes * 0.6 self.lblAssessment["text"] = "%.2f" % assessment #get property taxes taxestotal = (assessment / 100) * 0.64 self.lblTaxes["text"] = "%.2f" % taxestotal def main(): app = App() app.mainloop() if __name__ == "__main__": main() Pseudocode: START Import tkinter Create instance of class Tk called App Call __init__ method for object Call __init__ method for Tk def addTaxes Create label (Property) and input for GUI def addOutput Create button for GUI Create label (Assessment) and output for GUI Create label (Property Taxes) and output for GUI def calculate taxes = input from addTaxes assessment = taxes * 0.6 Output label (Assessment) = assessment taxestotal = (assessment / 100) * 0.64 Output label (Property Taxes) = taxestotal def main() call Class App() END START END START Import tkinter Create Instance of Class Tk called App END Call App Def main() Prompt user for Property Value Read user input Read button command Input = taxes Assessment = taxes * 0.6 Property Taxes = Assessment * 0.65 Display Assessment and Property Taxes

Upload: andrew-carts

Post on 01-Feb-2016

108 views

Category:

Documents


0 download

DESCRIPTION

Assignment 10

TRANSCRIPT

Page 1: Assignment 10

Python Code

from tkinter import *

class App(Tk): def __init__(self): Tk.__init__(self)

self.headerFont = ("Helvetica", "16", "bold italic") self.title("Assessor Software") self.addTaxes() self.addOutput() def addTaxes(self): Label(self, text = "Assessor Program", font = self.headerFont).grid(columnspan = 3) Label(self,justify=CENTER, text = "Enter Property Value").grid(row = 1, column = 0) self.txtProperty = Entry(self) self.txtProperty.grid(row = 1, column = 3) self.txtProperty.insert(0, "<enter value here>")

def addOutput(self): self.btnCalc = Button(self, wraplength=120, text = "Calculate Assessment Value and Property Taxes") self.btnCalc.grid(row = 10, columnspan = 3) self.btnCalc["command"] = self.calculate

Label(self, text = "Assessment Value").grid(row = 11, column = 0) self.lblAssessment = Label(self, bg = "#fff", anchor = "w", relief = "groove") self.lblAssessment.grid(row = 11, column = 3, sticky = "we")

Label(self, text = "Property Tax").grid(row = 12, column = 0) self.lblTaxes = Label(self, bg = "#fff", anchor = "w", relief = "groove") self.lblTaxes.grid(row = 12, column = 3, sticky = "we") def calculate(self): taxes = int(self.txtProperty.get()) #get assessment assessment = taxes * 0.6 self.lblAssessment["text"] = "%.2f" % assessment

#get property taxes taxestotal = (assessment / 100) * 0.64 self.lblTaxes["text"] = "%.2f" % taxestotal def main(): app = App() app.mainloop()

if __name__ == "__main__": main()

Pseudocode:

STARTImport tkinterCreate instance of class Tk called App Call __init__ method for object Call __init__ method for Tk def addTaxes Create label (Property) and input for GUI def addOutput Create button for GUI Create label (Assessment) and output for GUI Create label (Property Taxes) and output for GUI def calculate taxes = input from addTaxes assessment = taxes * 0.6 Output label (Assessment) = assessment taxestotal = (assessment / 100) * 0.64 Output label (Property Taxes) = taxestotaldef main() call Class App()END

START

END

START

Import tkinter

Create Instance of Class Tk called App

END

Call App

Def main()

Prompt user for Property Value

Read user input

Read button command

Input = taxes

Assessment = taxes * 0.6

Property Taxes = Assessment * 0.65

Display Assessment and Property Taxes