I don’t know why it dont work even when I copy somone code it work but when I do my code it dont work .
I want to get the username and the password so I can verify the login else it will show a message box.
from tkinter import *
def login():
usrnam = username.get()
paswrd = password.get()
print(username)
root = Tk()
photo = PhotoImage(file='small logo.png')
root.geometry('300x500+450+100')
root.title('Clinique nouadhibou')
root.config(background='white')
root.iconphoto(True,photo)
label1 = Label(root, text="bonjour !", font=('Arial', 20, 'bold'), bg='white', fg='green', relief=RAISED, bd=10, image=photo, compound='top').pack()
username = Entry(root).place(x=95, y=320)
password = Entry(root, show='*').place(x=95, y=340)
who_is_this = Checkbutton(root).place(x=0, y=480)
button = Button(root, text='Enter !', command=login).place(x=137, y=360)
button = Button(root, text='SORTIR!', command=quit).place(x=130, y=470)
root.mainloop()
It give me this error:
File "clinique.py", line 14, in login
usrnam = username.get()
AttributeError: 'NoneType' object has no attribute 'get'
>Solution :
.place() returns None. You should declare the widget on one line, and place it on the next one, then reference the declaration.
Example:
# old code
username = Entry(root).place(x=95, y=320)
password = Entry(root, show='*').place(x=95, y=340)
# new code
username = Entry(root)
username.place(x=95, y=320)
password = Entry(root, show='*')
password.place(x=95, y=340)