1
Well I am making a python application using Tkinter, I made a login window after checking user and password I would like to open a system window and close the login window. I’m breaking my head and I can’t find the error, if anyone can help I’ll be very grateful. I’ve researched everything I tried to last . quit . but does not close.
from tkinter import *
from sistemas import Sistema
class loginJanela:
def __init__(self):
self.Janela = Tk()
self.Janela.title('nome')
self.Janela.iconbitmap('icone.ico')
w = self.Janela.winfo_screenwidth()
h = self.Janela.winfo_screenheight()
size = tuple(int(_) for _ in self.Janela.geometry().split('+')[0].split('x'))
x = w/2 - size[0]/2
y = h/2 - size[1]/2
self.Janela.geometry("280x280+%d+%d" % (x,y))
self.fontePadrao = ('Arial', "10")
self.container1 = Frame(self.Janela)
self.container1['pady'] = 20
self.container1.pack()
self.containerDados1 = Frame(self.Janela)
self.containerDados1['padx'] = 50
self.containerDados1.pack()
self.containerDados2 = Frame(self.Janela)
self.containerDados2['padx'] = 50
self.containerDados2.pack()
self.containerBotao = Frame(self.Janela)
self.containerBotao['pady'] = 30
self.containerBotao.pack()
self.titulo = Label(self.container1, text='LOGIN')
self.titulo['font'] = ('Arial', '10', 'bold')
self.titulo.pack()
self.loginId = Label(self.containerDados1, text='ID:')
self.loginId['font'] = self.fontePadrao
self.loginId.pack()
self.usuario = Entry(self.containerDados1)
self.usuario["width"] = 30
self.usuario.pack()
self.loginSenha = Label(self.containerDados2, text='Senha:')
self.loginSenha['font'] = self.fontePadrao
self.loginSenha.pack()
self.senha = Entry(self.containerDados2, show='*')
self.senha.bind('<Return>', self.verificaSenhaEnter)
self.senha["width"] = 30
self.senha.pack()
self.botao = Button(self.containerBotao, text='Entrar')
self.botao['font'] = ('Calibri', '10')
self.botao['width'] = 12
self.botao['command'] = self.verificaSenhaClick
self.botao.pack()
self.mensagem = Label(self.containerBotao, text='', font=self.fontePadrao)
self.mensagem.pack()
self.Janela.mainloop()
def sair(self):
self.Janela.quit()
def abreSistema(self):
self.container1.pack_forget()
self.containerDados1.pack_forget()
self.containerDados2.pack_forget()
principal = Tk()
principal.title('IMOBILIÁRIA SK')
principal.iconbitmap('icone.ico')
principal.geometry("800x600")
Sistema(principal)
principal.mainloop()
def verificaSenhaClick(self):
usuario = self.usuario.get()
senha = self.senha.get()
if usuario == '' and senha == '':
self.mensagem['text'] = 'Autenticado'
self.abreSistema()
self.sair()
else:
self.mensagem['text'] = 'Erro na autenticação'
def verificaSenhaEnter(self, event):
usuario = self.usuario.get()
senha = self.senha.get()
if usuario == 'skimoveis' and senha == 'senhasecreta':
self.mensagem['text'] = 'Autenticado'
self.abreSistema()
self.sair()
else:
self.mensagem['text'] = 'Erro na autenticação'
lp = loginJanela()
You tried to call the
self.Janela.destroy()
just before creating the new Tk instance (in the line before theprincipal = Tk()
) and it didn’t work? Some error message appears?– Gomiero
incredibly does not give any error and also does not close.
– Jefferson Dong Min Kwak
Even putting the
self.Janela.destroy()
a line before theprincipal = Tk()
? I tested it here in python 3.6 and it worked. Which python version do you use?– Gomiero
Thank you!! was that I put Destroy in the function of opening the system and it worked, I was putting in the function of user’s tool and password, but still do not understand the error why I can not close putting there
– Jefferson Dong Min Kwak