-1
I’m having a problem with the code, my code is bigger than that, this part is just the login and password part, my problem is that the code works if the window is closed by X, has how to check if the Tkinter window was closed by X and close the entire program if this was done?
#Criar janela de login
jan = Tk()
jan.title('Login System')
jan.geometry("250x150")
jan.resizable(width=False, height=False)
#Definir funções
def Logar():
User = en1.get()
Pass2 = en2.get()
DataBase.cur.execute("""
SELECT * FROM LoginUsers
WHERE (User = ? and Password = ?)
""", (User, Pass2))
VerifyLogin = DataBase.cur.fetchone()
try:
if User in VerifyLogin and Pass2 in VerifyLogin:
messagebox.showinfo(title='Login Info', message='Acesso Confirmado. Bem Vindo')
jan.destroy()
except:
messagebox.showerror(title='Login Info', message='Acesso Negado. Verifique se você esta cadastrado no sistema.')
def RegisterData():
Name = en1.get()
Pass = en2.get()
if Name == "" and Pass == "":
messagebox.showerror(title="Register Error", message="Preencha todos os camos")
else:
DataBase.cur.execute("""
INSERT INTO LoginUsers(User, Password) VALUES(?, ?)
""", (Name, Pass))
DataBase.conn.commit()
messagebox.showinfo(title="Register Info", message="Registrado Com Sucesso")
#Criar Widgets
text1 = Label(jan, text='Login: ')
text2 = Label(jan, text='Passworld: ')
en1 = Entry(jan)
en2 = Entry(jan, show='*')
bt1 = Button(jan, text='Confirm', command=Logar)
bt2 = Button(jan, text='Register', command=RegisterData)
#Posicionar Widgets
text1.grid(row=0, column=0)
text2.grid(row=1, column=0)
en1.grid(row=0, column=1)
en2.grid(row=1, column=1)
bt1.grid(row=2, column=1)
bt2.grid(row=3, column=1)
#Deixar a janela em loop
jan.mainloop()
Yeah, the X is that red
– Olho
https://github.com/VitorPL07/wizard These are the files.
– Olho
I believe so, but the q and q was going wrong with the code?
– Hugo Barbosa
If the user closes the login screen by X the program continues, and this is not supposed to happen. I want q if in case the user closes the window by X, the program exits
– Olho
how and know that the program does not come out completely what and q gives you that indication
– Hugo Barbosa
Because I tested, the program is I who am doing
– Olho