Using GUI to calculate pay, this is my code. I am not receivingan answer in the Weekly Pay = when inputting hours and pay rate.?
import tkinter
from tkinter import Label
from tkinter import Entry
from tkinter import Button
from tkinter import IntVar
def calculatewages():
hours=float(nhours.get())
nsal=float(nwage.get())
wage=nsal*hours
def wage(hours, rate):
pay = hours * rate
def hours_worked ():
if hours_worked > 40:
pay = pay + ((hours_worked – 40) * (pay_rate * .5))
labelresult=Label(myGUI,text=”Weekly Pay: $ %.2f” %wage).grid(row=7,column=2)
return
Tk = tkinter.Tk()
myGUI=Tk
myGUI.geometry(‘400×200+100+200’)
myGUI.title(‘Pay Calculator’)
nwage= IntVar()
nhours= IntVar()
label1=Label(myGUI,text=’Enter the number of hours worked forthe week’).grid(row=0, column=0)
label2=Label(myGUI,text=’Enter the pay rate’).grid(row=1,column=0)
label3=Label(myGUI,text=’Weekly Pay =’).grid(row=2, column=1)
mywage=Entry(myGUI,textvariable=nwage).grid(row=0,column=2)
myhours=Entry(myGUI,textvariable=nhours).grid(row=1,column=2)
payButton = Button (myGUI, text = “Calculate Pay”, font = (“Arial”,8, “bold”), bd=5, highlightbackground = “red”, activebackground =”green”, activeforeground=”blue”, command = calculatewages )
payButton.grid(row = 3, column = 1,ipady = 8, ipadx = 12, pady =5)
quitButton = Button (myGUI, text = “Quit”, font = (“Arial”, 8,”bold”), bd=5, highlightbackground = “red”, activebackground =”green”, activeforeground=”blue”, command = calculatewages )
quitButton.grid(row = 3, column = 2,ipady = 8, ipadx = 12, pady =5)
myGUI.mainloop()
– O X Pay Calculator Enter the number of hours worked for the week: Enter the pay rate: Weekly Pay = Calculate Pay Quit Show transcribed image text – O X Pay Calculator Enter the number of hours worked for the week: Enter the pay rate: Weekly Pay = Calculate Pay Quit
Expert Answer
Answer to Using GUI to calculate pay, this is my code. I am not receiving an answer in the Weekly Pay = when inputting hours and p…