Good day!
I'm working with the log in page using python. However, everytime i run my scripts, and click the Student button an error occurred.
from tkinter import *
def student():
screen1 = Toplevel(screen)
screen1.title("Student Log in")
screen1.geometry("300x250")
username = StringVar()
password = StringVar()
Label(screen1, text = "Username * ").pack()
Entry(screen1, textvariable = username)
Label(screen1, text = "Password * ").pack()
Entry(screen1, textvariable = password)
def main_screen():
screen = Tk()
screen.geometry("300x250")
screen.title("Database Project 1")
Label(text = "Database Project 1", bg = "grey", width = "300", height = "2", font = ("Calibri", 13)).pack()
Label(text = "").pack()
Button(text = "Student", height = "2", width = "30", command = student).pack()
Label(text = "").pack()
Button(text = "Teacher",height = "2", width = "30").pack()
screen.mainloop()
main_screen()
Error:
"File "C:/Users/TEMP.asus.001/Desktop/project database/Student database/main screen in tk.py", line 5, in student
screen1 = Toplevel(screen)
NameError: name 'screen' is not defined
So how i fix this error, my code seems correct though! "