my code was working fine before i added a block of code def startcheck(self):
and i'm not sure what's wrong with it. please tell me what im doing wrong, thanks. here's what it says:
Traceback (most recent call last):
File "C:/MathsQuiz/venv/test 2.py", line 138, in <module>
instance = Starting(root)
File "C:/MathsQuiz/venv/test 2.py", line 21, in __init__
self.usercont = Button(self.frame, text="Continue", command=self.startcheck())
_tkinter.TclError: bad window path name ".!frame"
here's a small part of my code:
class Starting:
def __init__(self, master):
self.master = master
self.usern = Label(self.frame,text="Please enter a username:", font=("16"))
self.usern.grid(row=1, padx=20, pady=20)
self.userentry = Entry(self.frame, width=50)
self.userentry.grid(row=2)
self.name = StringVar()
self.name.set(self.userentry.get())
self.usercont = Button(self.frame, text="Continue", command=self.startcheck())
self.usercont.grid(row=3)
def startcheck(self):
if self.name.get() == None:
nameerror = Label(self.frame, text="Please enter a username")
nameerror.grid(row=5)
else:
self.clear1()
def clear1(self):
self.frame.destroy()
Question1(root)
if __name__ == "__main__":
root = Tk()
root.title = ("Maths Quiz")
instance = Starting(root)
root.mainloop()