Jason (toomanywhispers) wrote in littlescripts,

A program to figure sales tax.

I took the groundwork I laid for my converter program and used it to write a program for calculating sales tax. Very little of the converter code survived the rewriting I did to incoporate grid managing of the different widgets. It looks a heck of alot more polished than Converter because of the grid managing.

# NYstax 0.1.0
# Created by Jason Capron
# Licenced under the GPL (Check your Python folder, including it here would be like appending a dictionary to a post-it note)
from Tkinter import *
def but1():
....a2 = a*.08
....b = (a+a2)
....print w.insert(INSERT,a2)
....print y.insert(INSERT,b)
v = StringVar()
w = Text(root,height=1, width=20)
w.grid(row=1, column=1)
TaxLab = Label(root, text="Tax")
TaxLab.grid(row=1, column=0)
y = Text(root, height=1, width=20)
y.grid(row=2, column=1)
TotLab = Label(root, text="Total with Tax")
TotLab.grid(row=2, column=0)
x = Label(root, text="Amount to convert")
x.grid(row=0, column=0)
e = Entry(root,textvariable=v, width=20)
b1 = Button(root,text="Calculate sales tax",command=but1)

What gave me migranes was getting the button to work after adding the grid code.
I was lumping things together like this

"b1 = Button(root,text="Calculate sales tax",command=but1).grid(row=3,columnspan=3)"

Instead of using two lines like this,

"b1 = Button(root,text="Calculate sales tax",command=but1)

To modify this scipt for your own state sales tax, just change "a2 = a*.08" (Line 11) to whatever the rate for sales tax is in your area. New Yorks is 8%, so the mulitplyer is .08
  • Post a new comment


    default userpic