Click here to Skip to main content
15,867,568 members

Comments by Tomas Sanchez Garcia (Top 11 by date)

Tomas Sanchez Garcia 14-Aug-23 4:40am View    
Sorry, already updated. More than anything I was trying to get an idea.
Tomas Sanchez Garcia 10-Aug-23 11:37am View    
Hi, thank you very much for your answer. I have tried testing this way with more statements and within the FOR loop, but it keeps giving me the same error, only one user reads me and not the others.

Regarding security, thanks for the information, this is only for the purpose of learning nothing professional for the public.

def validar(self):

if self.entry_email.get() == "" or self.entry_password.get() == "":
self.dialogo = tk.Toplevel()
self.dialogo.title("ERROR")
self.dialogo.geometry("300x50")
self.dialogo.resizable(0,0)

self.wtotal2 = self.dialogo.winfo_screenwidth()
self.htotal2 = self.dialogo.winfo_screenheight()

self.wventana2 = 300
self.hventana2 = 100

self.pwidth2 = round(self.wtotal2/2-self.wventana2/2)
self.pheight2 = round(self.htotal2/2-self.hventana2/2)

self.dialogo.geometry(str(self.wventana2)+"x"+str(self.hventana2)+"+"+str(self.pwidth2)+"+"+str(self.pheight2))
self.etiqueta = tk.Label(self.dialogo, text="Rellena todos los campos.", padx=10, pady=10)
self.etiqueta.pack()

self.image_boton_vale = Image.open("src/boton_vale.png")
self.photo_boton_vale = ImageTk.PhotoImage(self.image_boton_vale)

self.boton_vale = tk.Button(self.dialogo, image=self.photo_boton_vale, command=self.cerrar_dialogo_vale)
self.boton_vale.pack(pady=5)
self.boton_vale.place(x=86, y=50, width=128, height=31)
else:
self.connection2 = connect_to_database()
self.cursor2 = self.connection2.cursor()
# Ejemplo: Ejecutar una consulta para obtener datos
self.cursor2.execute("SELECT nombre,password FROM usuarios")
self.data2 = self.cursor2.fetchall()

for self.fila in self.data2:
self.v_email = self.fila[0]
self.v_password = self.fila[1]

if self.entry_email.get() == self.v_email and self.entry_password.get() == self.v_password:
self.app.root.destroy()
self.ventana_menu = Menus(self)
else:
self.app.root.destroy()
messagebox.showwarning("Advertencia", "Los datos introducidos son incorrectos.")

self.cursor2.close()
self.connection2.close()
Tomas Sanchez Garcia 6-Aug-23 7:32am View    
Hi, thank you very much.

If it has been solved.

I am very sorry for the inconvenience caused, I am trying to exercise and progress.

I'm learning with OOP and that's why I get a bit stuck, I try to make things more organized.

Thank you very much again, sorry for the inconvenience.
Tomas Sanchez Garcia 31-Jul-23 12:30pm View    
Hola, gracias a todos por vuestra ayuda. Ahora funciona y he logrado entender la lógica.

Ahora tengo esto así en la clase de inicio de sesión:
self.label_email = tk.Label(text=self.t_Email)

y antes era así:
self.label_email = tk.Label(self.root, text=self.t_Email)

¿Por qué tuve que eliminar el "self.root"? Me dio un error si lo puse.

¿La función ya detecta que esas etiquetas y entradas van en la ventana raíz?
Tomas Sanchez Garcia 31-Jul-23 5:30am View    
Thank you very much for your answer, but how could I make the validate function part of the login function? Forgive my ignorance but I got a little stuck in this part.

thank you