можете ли вы сравнить текст поля ввода с желаемым именем пользователя и паролем и вставить его в операторы if-else, чтобы выполнять различные функции при нажатии кнопки? Я не могу сделать это с помощью IDK функции .get (), почему она не работает или что-то не так с моим кодом.
from tkinter import*
root =Tk()
header=Label(root ,text='Welcome to pokedex')
header.pack()
usernameLabel=Label(root,text="Username")
usernameLabel.pack()
a=""
b=""
usernameEntry=Entry(root,width=50)
usernameEntry.pack()
def usernameentry():
a=usernameEntry.get()
b_1=Button(root,text="_/",command=usernameentry)
b_1.pack()
passwordLabel=Label(root,text="Password")
passwordLabel.pack()
passwordEntry=Entry(root,width=50)
passwordEntry.pack()
def passwordentry():
b=passwordEntry.get()
b_2=Button(root,text="_/",command=passwordentry)
b_2.pack()
def correctpass():
correctpassLabel=Label(root,text="Welcome to pokedex")
correctpassLabel.pack()
def wrongpass():
wrongpassLabel=Label(root,text="Sorry wrong username or password")
wrongpassLabel.pack()
if a=="Malhar"and b=="123" :
loginButton=Button(root,text="Login",command=correctpass)
loginButton.pack()
else:
loginButton=Button(root,text="Login",command=wrongpass)
loginButton.pack()
root.mainloop()