I'm trying to make a login system in Tkinter using Python. So the way I want to do it is by asking the user for a username. When they click next the username field should dissapear and a new field named password should appear instead. So when I tried to do this I get an error:
e1 is not defined in line 27, in button
I understand that the variable has not been declared yet, but it should have done it, as I have put everything in a main() function.
This is my code
from tkinter import *
from tkinter import messagebox
root = Tk()
root.title("Loginsystem")
root.geometry("300x200")
def main():
def username_page():
Label(root, text="Username").place(x=10, y=10)
e1 = Entry(root)
e1.place(x=140, y=10)
uname = e1.get()
def password_page():
Label(root, text="Password").place(x=10, y=40)
e2 = Entry(root)
e2.place(x=140, y=40)
e2.config(show="*")
def button():
#Hide the username input field
e1.delete()
#Show the password input field
password_page()
username_page()
Button(root, text="Next", command=button, height = 3, width = 35, background = "blue", foreground = "white").place(x=10, y=100)
root.mainloop()
main()