Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from cgitb import text
- from statistics import variance
- from tabnanny import check
- from tkinter import *
- from tkinter import messagebox
- def ShowCalculation(service,gst,calculated):
- root2 = Tk()
- root2.title("Result")
- root2.geometry("50x80")
- label = Label(root2, text="Gst RM{}\nService Tax RM{}\n\nTotal RM{}".format(round(gst,2),round(service,2),round(calculated,2)))
- label.place(x=1,y=1)
- root2.mainloop()
- def Calculate():
- price = enterPrice.get()
- gstTax = 0.035
- serviceTax = 0.075
- totalGst = 0
- totalService = 0
- if (price == "") :
- # Widget 5
- messagebox.showerror("ERROR : 0XXDES324", "Please enter some input to calculate!")
- return
- if (price.isnumeric() == False) :
- # Widget 5
- messagebox.showerror("ERROR : 0XXDES223", "Please enter numeric value!")
- return
- print(checkGst.get())
- if(checkGst.get() == 1):
- totalGst = int(price) * gstTax
- print(totalGst)
- if(checkService.get() == 1):
- totalService = int(price) * serviceTax
- print(totalService)
- ShowCalculation(totalService,totalGst,int(price) - int(totalGst) - int(totalService))
- root = Tk()
- root.title("LAB TASK 4")
- root.geometry("135x160")
- root.resizable(0,0)
- checkGst = IntVar()
- checkService = IntVar()
- # Widget 1
- label1 = Label(root, text=" TAX CALCULATOR\n ENTER PRICE")
- label1.place(x=5,y=1)
- # Widget 2
- enterPrice = Entry(root, textvariable="Enter Price RM")
- enterPrice.place(x=5, y = 50)
- # Widget 3
- checkButton = Checkbutton(root, text="Service tax", variable = checkService)
- checkButton.place(x=25, y = 75)
- # Widget 3
- checkButton = Checkbutton(root, text="Gst tax", variable = checkGst)
- checkButton.place(x=25, y = 100)
- # Widget 4
- btnConfirm = Button(root, text ="Confirm",width=10,fg='brown', bg='light green', command=Calculate)
- btnConfirm.place(x=20,y=125)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement