Python Forum

Full Version: Errors in code
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I've been trying to figure out what I need to edit in this code to make it run properly. I wasn't sure where to post this in the forums so just decided to make a new post. Any help with this is definitely appreciated.


from Tkinter import * # import everything from the Tkinter GUI framework def calculate_age() # calculate the pay and display
global age# global variable called pay e1.focus_set( e2=Label(master, text="No Age Calculated ").grid(row=2,column=0) days= 365*float(e1.get()
e2=Label(master, text=" ".grid(row=2,column=0)
e2=Label(master, text="Age in days is +str(days)).grid(row=2,column=0 e1.delete(0,'end')
def close_window() # close menu window and stop program master.destroy()
master = Tk(
Label(master, text="Enter your age in years:").grid(row=0) Label(master, text="Your age in days is ").grid(row=2)
e1 = Entry(master)
e2 = Label(master)
e1.grid(row=0, column=1)
e2.grid(row=1, column=1
# Buttons
Button(master, text='Calc', command=calculate_age).grid(row=4, column=1, sticky=W, pady=4)
Button(master, text='Quit', command=close_window).grid(row=4, column=0, sticky=W, pady=4) Master.geometry("350,200"
master.title("AssessErrors")
#mainloop( )
Master.destroy()
Couple things:
Firstly, what have you tried in making it work?
Secondly, where in the world did you get this code from? There are so many problems.

Have a try at fixing it yourself - it's not as bad as it seems.
Code:
(Dec-02-2019, 03:18 PM)DreamingInsanity Wrote: [ -> ]Couple things:
Firstly, what have you tried in making it work?
Secondly, where in the world did you get this code from? There are so many problems.

Have a try at fixing it yourself - it's not as bad as it seems.
Code:

I'm new to Python so some of the code I've written myself and some I've had to search for on Google. I think I've mixed a few things up so that is probably why I've had so many problems. I've tried to space the code out and comment out individual lines to fix it. My problem I think was it was trying to do too many things. I think I'll be fine with it now. Thank you for at least having a look at it though, really appreciate it.