Login usuarios
Publicado por Alejandro (5 intervenciones) el 12/10/2022 17:46:50
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import tkinter as tk
import json
archivo = open("usuarios.json", "r")
contenido = archivo.read()
datos = json.loads(contenido)
archivo.close()
ventana = tk.Tk()
ventana.geometry("640x480+350+150") #tamaño de ventana
ventana.title("Mi ventana ") #titulo ventana
ventana.resizable(0,0) #Bloquear la ventana para que no maximise
usuario = tk.Label(ventana, text="Username",font=("Arial",18, "bold"))
usuario.place(x=25,y=150)
contasena = tk.Label(ventana, text="Pasword",font=("Arial",18, "bold"))
contasena.place(x=25,y=230)
variable1 = tk.StringVar()
resultado = tk.Label(ventana, textvariable=variable1,font=("Arial",18, "bold"))
resultado.place(x=220,y=300)
texto1 = tk.StringVar()
entradaTexto1 = tk.Entry(ventana, textvariable=texto1, font=("Arial",20))
entradaTexto1.place(x=200, y=150)
texto2 = tk.StringVar()
entradaTexto2 = tk.Entry(ventana, textvariable=texto2,show="*", font=("Arial",20))
entradaTexto2.place(x=200, y=230)
def buscarUsuario():
a = texto1.get()
b = texto2.get()
print(a)
print(b)
for i in datos["usuarios"]:
if i["usuario"] == a and i["contrasena"] == b:
variable1.set("Usuario Correcto")
else:
variable1.set("Usuario Incorrecto")
boton1 = tk.Button(ventana,text="Login",width=7,font=("Arial",20),command=buscarUsuario)
boton1.place(x=270, y=350)
ventana.mainloop() # Es que tengo un error y no lo he podido hallar a la hora de validar los usuarios siempre
#me muestra usuario incorrecto asi las credenciales que ingrese sean correctas
Valora esta pregunta


0