I am trying to make a record management system using tkinter but I am always getting this exception in tkinter callback error.
from tkinter import *
root2 = Tk()
root2.geometry('700x420')
def submit():
firstname = e_firstname.get()
lastname = e_lastname.get()
age = e_age.get()
phone_number = e_phone_number.get()
print(firstname)
print(lastname)
print(age)
print(phone_number)
Label(root2, text="Tilka Manjhi International Hospital Appointments", font=("Aharoni bold", 17)).grid(row=0, column=0, columnspan=2)
Label(root2, text="").grid(row=1)
Label(root2, text="First Name :" ,font=("ariel bold", 17)).grid(row=2, column=0)
e_firstname = Entry(root2, bd=5, width=40).grid(row=2, column=1)
Label(root2, text="").grid(row=3)
Label(root2, text="Last Name :" ,font=("ariel bold", 17)).grid(row=4, column=0)
e_lastname = Entry(root2, bd=5, width=40).grid(row=4, column=1)
Label(root2, text="").grid(row=5)
Label(root2, text="Age :" ,font=("ariel bold", 17)).grid(row=6, column=0)
e_age = Entry(root2, bd=5, width=40).grid(row=6, column=1)
Label(root2, text="").grid(row=7)
Label(root2, text="Phone Number :" ,font=("ariel bold", 17)).grid(row=8, column=0)
e_phone_number = Entry(root2, bd=5, width=40).grid(row=8, column=1)
Button(root2, text="Submit", command=submit).grid(row=9, column=1)
root2.mainloop()
I am always getting this error no matter how I change this code and still I dont get what I am doing wrong here.
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Hp\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 1884, in __call__
return self.func(*args)
File "c:\Users\Hp\Desktop\python\project\patientbacklog.py", line 8, in submit
firstname = efirstname.get()
AttributeError: 'NoneType' object has no attribute 'get'