when I try to run my code, I get a lot of errors, and i don't even know what these are saying. there's a few errors and all just say the code and doesn't say the error: I'll put down the error message and also my code, please tell me what the errors are and how I can fix it, thanks. I just started this code which is why there are so little things and I'm sort of new to Tkinter.
Error Message.
File "C:/MathsQuiz/venv/mainmaths.py", line 31, in <module>
instance = Starting(root)
File "C:/MathsQuiz/venv/mainmaths.py", line 13, in __init__
self.usern = Label(root.frame, text="Please enter a username", font=("16"))
File "C:\Users\marky\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 3143, in __init__
Widget.__init__(self, master, 'label', cnf, kw)
File "C:\Users\marky\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 2561, in __init__
BaseWidget._setup(self, master, cnf)
File "C:\Users\marky\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 2530, in _setup
self.tk = master.tk
AttributeError: 'function' object has no attribute 'tk'
Process finished with exit code 1
Here is my code.
from tkinter import *
import random
x = random.randint(5, 12)
y = random.randint(5, 12)
class Starting:
def __init__(self, master):
self.frame = Frame(master, padx=200, pady=200)
self.frame.grid()
self.title = Label(self.frame, text="Multi-level Maths Quiz", font=("Helvetica", "20", "bold"))
self.title.grid(row=0, padx=30, pady=30)
self.usern = Label(root.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.usercont = Button(self.frame, text="Continue", COMMAND=clear1)
self.usercont.grid(row=3)
def clear1(self):
self.frame.destroy()
if __name__ == "__main__":
root = Tk()
root.title = ("Maths Quiz")
instance = Starting(root)
root.mainloop()