Fechar janela (usando Tkinter)
from tkinter import *
def fechar():
root.destroy()
root = Tk()
root.geometry('300x100')
root.title('Fechar a janela')
root.resizable(False,False)
butao = Button(root, text='Fechar a janela', command=fechar)
butao.place(relx=0.35,rely=0.35)
root.mainloop()
# Exemplo 2
from tkinter import *
from tkinter import messagebox as mb
def funcaobutao():
pergunta=mb.askquestion('Sair da Aplicação', 'Quer sair da Apliação')
if pergunta == 'yes':
root.destroy()
else:
mb.showinfo('Informação', 'Voltar à Aplicação')
root = Tk()
root.geometry('300x100')
root.title('Fechar a janela')
root.resizable(False,False)
butao = Button(root, text='Fechar a janela', command=funcaobutao)
butao.place(relx=0.35,rely=0.35)
root.mainloop()
# Exemplo 3
from tkinter import *
from tkinter import messagebox as mb
def funcaobutao():
mb.showinfo('Informação', 'Fechar a Aplicação')
root.destroy()
root = Tk()
root.geometry('300x100')
root.title('Fechar a janela')
root.resizable(False,False)
butao = Button(root, text='Fechar a janela', command=funcaobutao)
butao.place(relx=0.35,rely=0.35)
root.mainloop()
Comentários
Enviar um comentário