PYTHON Tkinter buttons which call a function.
I have a function run from a main menu which creates a data entry form for payroll.
I have a button on that form which takes the gross pay figure from the payroll form and passes it into a function to work out deductions like tax, pension etc and ultimately net pay. This deductions and net pay then need to be displayed on the form, bit like a wage slip.
I can pass the multiple values back ok but how can I get those separate values populated onto the form in the correct fields? I am a novice programmer.
def openWagesWindow():
WagesWindow=tk.Tk()
WagesWindow.title("Wages")
WagesWindow.geometry("800x600")
windowlabel = tk.Label(WagesWindow, text ="Payroll")
windowlabel.pack()
Grosslabel = tk.Label(WagesWindow, text= 'Gross Pay')
Grosslabel.pack()
Grossentry = tk.Entry(WagesWindow)
Grossentry.insert(0,int(0))
Grossentry.pack()
TaxLabel = tk.Label(WagesWindow, text= 'Tax')
TaxLabel.pack()
Taxentry = tk.Entry(WagesWindow)
Taxentry.pack()
NILabel = tk.Label(WagesWindow, text= 'National Insurance')
NILabel.pack()
NIentry = tk.Entry(WagesWindow)
NIentry.pack()
PensionLabel = tk.Label(WagesWindow, text= 'Pension')
PensionLabel.pack()
Pensionentry = tk.Entry(WagesWindow)
Pensionentry.pack()
Deductlabel = tk.Label(WagesWindow, text= 'Deductions')
Deductlabel.pack()
Deductentry = tk.Entry(WagesWindow)
Deductentry.pack()
NetPaylabel = tk.Label(WagesWindow, text= 'Net Pay')
NetPaylabel.pack()
NetPayentry = tk.Entry(WagesWindow)
NetPayentry.pack()
backbutton = tk.Button(WagesWindow, text= "Back", command= WagesWindow.destroy)
backbutton.place(x=350, y=350)
calcbutton = tk.Button(WagesWindow, text= "Calculate",
command = lambda:CalcWages(Grossentry.get()))
calcbutton.place(x=400, y=350)
calcbutton = tk.Button(WagesWindow, text= "Calculate",
command = lambda:CalcWages(Grossentry.get()))
def CalcWages(Grosspay):
GP = int(Grosspay)
TX = GP *0.2
NI = GP *0.14
PNS = GP * 0.08
DEDUCT= TX+NI+PNS
NET= GP-DEDUCT
return[TX,NI,PNS,DEDUCT,NET]