I have the Login class and created an instance of it in the Main class, with the instance I'm calling the start method, however in the start method when clicking the 'Log in' button the method 'show_entry_fields' is not executed correctly. When I run and click the Main class I immediately get to the console: 'wrong login'. That is, I do not know why, but it is executing the 'else' directly, without having to click on the button (the if is not running). Can anyone help or explain what I did wrong? Follow the code for both classes
from tkinter import *
class Login:
@staticmethod
def show_entry_fields(nome, senha):
if nome == 'admin' and senha == 'admin':
master.destroy()
else:
print('login errado')
@staticmethod
def iniciar():
master = Tk()
Label(master, text='Usuário').grid(row=0)
Label(master, text='Senha').grid(row=1)
e1 = Entry(master)
e2 = Entry(master)
e1.grid(row=0, column=1)
e2.grid(row=1, column=1)
Button(master, text='Sair', command=master.quit).grid(row=3, column=0, sticky=W, pady=4)
Button(master, text='Logar', command=Login.show_entry_fields(e1.get(), e2.get())).grid(row=3, column=1, sticky=W, pady=4)
mainloop()
Main class:
from FechaLogin import Login
g = Login()
g.iniciar()