lundi 21 juin 2021

How can I make a password with if and the text of a label?

I made a command so that when pressing a button, a text is added to a label, and what I want to achieve is that if you put the correct combination, and then press a button to confirm, then a window opens with some text that I will choose later. The thing is, I don't know how to make a text from a lab work to make an if :( The text of "trad" is what I want the password to be

def salir():
    global posx    #variables de alcance para todo el script no solo la función
    global posy
    global ima

    if 

def a():
    trad.config(text=trad["text"]+"ar.")

def b():
    trad.config(text=trad["text"]+"ab.")
    
def i():
    trad.config(text=trad["text"]+"iz.")
    
def d():
    trad.config(text=trad["text"]+"de.")
    


ventana=tk.Tk()
ventana.title("Bosque")
ventana.geometry('900x800')
ventana.resizable(0,0)

frame = tk.Frame(ventana)
frame.pack()

canvas = tk.Canvas(frame, width=900, height=800)
canvas.pack()

image=tk.PhotoImage(file="labetinto.gif")
canvas.create_image(450,400,image=image)


myimg = tk.PhotoImage(file='circlo.png')
posx=70
posy=235
ima = canvas.create_image(78,235,image=myimg)

frame2 = tk.Frame(ventana)
frame.pack()
canvas2 = tk.Canvas(frame2, width=900, height=800)
canvas.pack()

image2=tk.PhotoImage(file="muros.png")
canvas.create_image(450,400,image=image2)


sal = "¿Qué camino debería tomar?"
leta = ""

trad = tk.Label(ventana,text=leta,wraplength=220,anchor="n")
trad.config(bg="#137420", fg="#E59866",font=("Verdana",10,"bold","italic"),width=25, height=9)
trad.place(x=660,y=160)

#caja = tk.Entry(ventana, width=37)
#caja.place(x=660,y=200)


boton = tk.Button(text="  ↑  ",font=("Verdana",17), command=a)
boton.config(bg="#135C3F", fg="#D7D731")
boton.place(x=745,y=330)

boton1 = tk.Button(text="  ↓  ",font=("Verdana",17), command=b)
boton1.config(bg="#135C3F", fg="#D7D731")
boton1.place(x=745,y=423)

boton2 = tk.Button(text="  Ir  ",font=("Verdana",16), command=salir)
boton2.config(bg="#135C3F", fg="#D7D731")
boton2.place(x=746,y=379)

boton3 = tk.Button(text=" → " ,font=("Verdana",17), command=d)
boton3.config(bg="#135C3F", fg="#D7D731")
boton3.place(x=812,y=376)

boton4 = tk.Button(text=" ← ",font=("Verdana",17), command=i)
boton4.config(bg="#135C3F", fg="#D7D731")
boton4.place(x=686,y=376)
ventana.mainloop()

Aucun commentaire:

Enregistrer un commentaire