Advertisement
enkacang

Untitled

Jun 14th, 2022
790
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.94 KB | None | 0 0
  1. from cgitb import text
  2. from statistics import variance
  3. from tabnanny import check
  4. from tkinter import *
  5. from tkinter import messagebox
  6.  
  7. def ShowCalculation(service,gst,calculated):
  8.     root2 = Tk()
  9.     root2.title("Result")
  10.     root2.geometry("50x80")
  11.  
  12.     label = Label(root2, text="Gst RM{}\nService Tax RM{}\n\nTotal RM{}".format(round(gst,2),round(service,2),round(calculated,2)))
  13.     label.place(x=1,y=1)
  14.  
  15.     root2.mainloop()
  16.  
  17. def Calculate():
  18.    
  19.     price = enterPrice.get()
  20.     gstTax = 0.035
  21.     serviceTax = 0.075
  22.     totalGst = 0
  23.     totalService = 0
  24.  
  25.     if (price == "") :
  26.         # Widget 5
  27.         messagebox.showerror("ERROR : 0XXDES324", "Please enter some input to calculate!")
  28.         return
  29.  
  30.     if (price.isnumeric() == False) :
  31.         # Widget 5
  32.         messagebox.showerror("ERROR : 0XXDES223", "Please enter numeric value!")
  33.         return
  34.  
  35.     print(checkGst.get())
  36.  
  37.     if(checkGst.get() == 1):
  38.         totalGst = int(price) * gstTax
  39.         print(totalGst)
  40.  
  41.     if(checkService.get() == 1):
  42.         totalService = int(price) * serviceTax
  43.         print(totalService)
  44.  
  45.     ShowCalculation(totalService,totalGst,int(price) - int(totalGst) - int(totalService))
  46.  
  47.  
  48.  
  49. root = Tk()
  50. root.title("LAB TASK 4")
  51. root.geometry("135x160")
  52. root.resizable(0,0)
  53.  
  54. checkGst = IntVar()
  55. checkService = IntVar()
  56.  
  57. # Widget 1
  58. label1 = Label(root, text="   TAX CALCULATOR\n      ENTER PRICE")
  59. label1.place(x=5,y=1)
  60.  
  61. # Widget 2
  62. enterPrice = Entry(root, textvariable="Enter Price RM")
  63. enterPrice.place(x=5, y = 50)
  64.  
  65. # Widget 3
  66. checkButton = Checkbutton(root, text="Service tax", variable = checkService)
  67. checkButton.place(x=25, y = 75)
  68.  
  69. # Widget 3
  70. checkButton = Checkbutton(root, text="Gst tax", variable = checkGst)
  71. checkButton.place(x=25, y = 100)
  72.  
  73. # Widget 4
  74. btnConfirm = Button(root, text ="Confirm",width=10,fg='brown', bg='light green', command=Calculate)
  75. btnConfirm.place(x=20,y=125)
  76.  
  77. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement