I just started learning python and wanted to make a simple login GUI. I tried following a tutorial, but for some reason, my code always gets an error. Here's the error: line 18, in sign_in print(f"My username is {username.get()} and my password is {password.get()}") AttributeError: 'NoneType' object has no attribute 'get'
from tkinter import *
main_window = Tk()
# ---------- LABELS ----------
Label(main_window, text = "Username: ").grid(row = 0, column = 0)
Label(main_window, text = "Password: ").grid(row = 1, column = 0)
# ---------- TEXT INPUT ----------
username = Entry(main_window, width = 50, borderwidth = 3.5).grid(row = 0, column = 1)
password = Entry(main_window, width = 50, borderwidth = 3.5, show = "*").grid(row = 1, column = 1)
# ---------- METHODS ----------
def sign_in():
print(f"My username is {username.get()} and my password is {password.get()}")
# ---------- BUTTON ----------
Button(main_window, text = "Sign In", command = sign_in).grid(row = 2, column = 1)
# ---------- MAIN LOOP ----------
main_window.mainloop()