You were setting/configuring your widgets in your class Autenticar
but you weren’t instating it anywhere, I’ve improved the structure of your code a little bit, do it like this:
from tkinter import *
class Autenticar():
def __init__(self):
self.main = Tk()
self.mount_gui()
def mount_gui(self):
self.main.geometry("250x250")
self.main.title("Autenticar")
self.Lab1 = Label(self.main, text = "Usuário", fg = "Blue")
self.Lab1.pack()
self.Entr1 = Entry(self.main)
self.Entr1.pack()
self.Lab2 = Label(self.main, text = "Senha", fg = "Blue")
self.Lab2.pack()
self.Entr2 = Entry(self.main)
self.Entr2.pack()
self.Bot1 = Button(self.main, text = "Confirmar", fg = "Black", command = self.AcessoNegado )
self.Bot1.pack()
self.main.mainloop()
def AcessoNegado(self):
self.Entr1.get()
self.Lab1["text"] = "Usuario Invalido"
self.Lab1["fg"] = "Red"
Autenticar()
I’ve been having a bit of fun with this, and I’ve made a functional example of hitting/missing creds (user: Jefferson_andr, pass: password):
from tkinter import *
class Autenticar():
def __init__(self):
self.main = Tk()
self.password = 'password'
self.usuario = 'Jefferson_Andr'
self.mount_gui()
def mount_gui(self):
self.main.geometry("250x250")
self.main.title("Autenticar")
self.Lab1 = Label(self.main, text = "Usuário", fg = "Blue")
self.Lab1.pack()
self.Entr1 = Entry(self.main)
self.Entr1.pack()
self.Lab2 = Label(self.main, text = "Senha", fg = "Blue")
self.Lab2.pack()
self.Entr2 = Entry(self.main)
self.Entr2.pack()
self.Bot1 = Button(self.main, text = "Confirmar", fg = "Black", command = self.auth )
self.Bot1.pack()
self.main.mainloop()
def auth(self):
if(self.Entr1.get() != self.usuario or self.Entr2.get() != self.password):
self.AcessoNegado()
return None
self.AcessoPermitido()
def AcessoPermitido(self):
self.Entr1.get()
self.Lab1["text"] = "Olá {}".format(self.usuario)
self.Lab1["fg"] = "Green"
def AcessoNegado(self):
self.Entr1.get()
self.Lab1["text"] = "Usuario Invalido"
self.Lab1["fg"] = "Red"
Autenticar()