Python "take not Arguments" error

Asked

Viewed 32 times

0

I was doing a login screen test but there is always an error saying that has no arguments and my login screen is without the part of typing the user and password only shows the window, and I looked and all the names are written in the same waya descrição do erro

inserir a descrição da imagem aqui

from tkinter import*

class Principal: #cria a classe principal
    def _init_(self, master=None):
        self.fontePadrao = ("Arial","10")
        self.Container1 = Frame(master)
        self.Container1["pady"]=10
        self.Container1["bg"]="light green"
        self.Container1.pack()

    self.Container2 = Frame(master)
    self.Container2["padx"]=20
    self.Container2["bg"]="light green"
    self.Container2.pack()

    self.Container3 = Frame(master)
    self.Container3["padx"]=20
    self.Container3["bg"]="light green"
    self.Container3.pack()

    self.Container4 = Frame(master)
    self.Container4["pady"]=20
    self.Container4["bg"]="light green"
    self.Container4.pack()

    self.titulo = Label(self.Container1, text="Dados do usuário:")
    self.titulo["font"] = ("Arial","10","bold")
    self.titulo["bg"]="light green"
    self.titulo.pack()

    self.nomeLabel = Label(self.Container2, text="Nome:", font=self.fontePadrao)
    self.nomeLabel["bg"]="light green"
    self.nomeLabel.pack(side=LEFT)

    self.nome = Entry(self.Container2)
    self.nome.focus()
    self.nome["width"]=30
    self.nome["font"] = self.fontePadrao
    self.nome.pack(side=LEFT)

    self.senhaLabel = Label(self.Container3, text="Senha:", font=self.fontePadrao)
    self.senhaLabel["bg"]="light green"
    self.senhaLabel.pack(side=LEFT) #kkkk

    self.senha = Entry(self.Container3)
    self.senha["width"]=30
    self.senha["font"] = self.fontePadrao
    self.senha["show"] = "*"
    self.nome.pack(side=LEFT)


    self.autentificar = Button(self.Container4)
    self.autentificar["text"] = "AUTENTIFICAR"
    self.autentificar["font"] = ("Calibri","10","bold")
    self.autentificar["width"] = 12
    self.autentificar["bg"] = "white"
    self.autentificar["command"] = self.verificaSenha
    self.autentificar.pack()

    self.sair = Button()
    self.sair["text"] = "SAIR"
    self.sair["font"] = ("Calibri","10","bold")
    self.sair["width"] = 5
    self.autentificar["command"] = quit
    self.sair.pack(side=TOP)

    self.mensagem = Label(self.Container4, text="",font=self.fontePadrao)
    self.mensagem["bg"] = "light green"
    self.mensagem.pack()


def verificaSenha(self):
    usuario = self.nome.get()
    senha = self.senha.get()

    if usuario == "Rafael" and senha =="123456789":
        self.mensagem["text"]="Autentificado!"
        self.nome["fg"]="gray"
        self.senha["fg"]="gray"
        self.sair.focus_force()
    else:
        self.mensagem["text"] = "Usuário e/ou senha incorretos!"
        self.senha.delete(0,END)
        self.nome.delete(0,END)
        self.nome.focus()



tela = Tk()
tela.title("TELA DE LOGIN")
tela["bg"] = "light green"
tela.geometry("400x250")
Principal(tela)
tela.mainloop()

1 answer

0


I believe that the error in your code is only the function "init". It is only with 1 underline on each side.

The class constructor in Python is __init__.

Edit1:

Around line 45, there is an error in container pack.

self.senha = Entry(self.Container3)
self.senha["width"]=30
self.senha["font"] = self.fontePadrao
self.senha["show"] = "*"
self.nome.pack(side=LEFT)                    <----- Deveria ser self.senha.pack(side=LEFT)
  • I thought it was just an underscore on each side, and I didn’t even see the error of the line 45 rs thank you very much this all right now

Browser other questions tagged

You are not signed in. Login or sign up in order to post.