I have the following code with a form class that calls the componentes.py
module that contains some basic functions to generate basic forms.
In principle only the user login and password is created, until then it goes well, but then I created another madulo called verify where I am trying to check in some way user and password, but the problem is that when using command
of the button I call the function to check the module verify this does not wait for me to press the "enter" button to perform this function but it runs automatically and as I did not place anything directly triggers the error message. Then it allows me to put username and password but pressing "enter" says that an argument is missing ( TypeError: chequear() missing 1 required positional argument: 'lista'
).
I will appreciate your help because I want to solve this simple exercise that I proposed and it is costing me.
import tkinter as tk
import componentes as cpt
import verificar as vf
""" FORMULARIO DE INGRESO permite accder a la app en si """
class Formularios():
def __init__(self):
self.listaCaja=[]
self.listaBoton=[]
self.listaEtiqueta=[]
self.comando=[]
#----------- VENTANA ACCESO -----------
def acceso(self):
lista=("USUARIO:", "CLAVE:")
lista2=("ENTRAR", "SALIR")
raiz=tk.Tk()
raiz.resizable(0, 0)
raiz.title("Ingreso de Usuarios")
marcoUno=tk.Frame(raiz, width="200", height="100")
marcoUno.grid(column=0, row=0)
marcoDos=tk.Frame(raiz, width="200", height="50")
marcoDos.grid(column= 0, row=1)
#----------- ETIQUETAS mUNO-----------
for i in range(len(lista)):
self.listaEtiqueta.append(cpt.crear_E(marcoUno, lista[i]))
cpt.ordenar(self.listaEtiqueta[i], i, 0, 5)
#----------- CAJAS TEXTO mUNO-----------
for i in range(len(lista)):
self.listaCaja.append(cpt.crear_C(marcoUno, "20"))
cpt.ordenar(self.listaCaja[i], i, 1, 5, 5)
#----------- BOTONES mDOS-----------
vf.chequear(self.listaCaja)
self.comando=[vf.chequear, quit]
for i in range(len(lista2)):
self.listaBoton.append(cpt.crear_B(marcoDos, lista2[i], "10", self.comando[i]))
cpt.ordenar(self.listaBoton[i], 0, i, 5, 2, "", 1)
raiz.mainloop()
raiz=Formularios()
raiz.acceso()
# ----componentes.py-----
import tkinter as tk
"""Este módulo está orientado a crear componentes sencillos de un formulario"""
#---------- ORDENAR ELEMENTOS ------------------
def ordenar(obj="", fila=0, col=0, x=0, y=0, coord="", cols=1, rows=1):
obj.grid(row=fila, column=col, padx=x, pady=y, sticky=coord, columnspan=cols, rowspan=rows)
#---------- CREAR ELEMENTOS ------------------
def crear_E(contenedor, titulo=""):
etiqueta=tk.Label(contenedor, text= titulo)
return etiqueta
def crear_C(contenedor, ancho="15"):
caja=tk.Entry(contenedor, width= ancho)
return caja
def crear_B(contenedor, titulo="", ancho="10", comando=""):
boton=tk.Button(contenedor, text=titulo, width=ancho, command=comando)
return boton
# ----verifica.py-----
from tkinter import messagebox
def chequear(lista):
if lista[0].get() == 1 and lista[1].get() == 2:
print("ok")
else:
messagebox.showwarning(title= "Denegado", message= "Su autenticación es Incorrecta")