0

I have a main window, and a button inside of this one, I open another window, which is closed by another button. How is it possible that once the latter is closed you can not reopen it? I attach the code of the two programs.

FIRST PROGRAM

from tkinter import *
def funzBottoCli():import nuovaprova

root = Tk()

root.state('zoomed')

root.title("Gestionale")

bottonCli = Button(root, text="  Apertura altra finestra   ", fg=('red'),    
font=('arial',10,'bold'), relief='raised', command=funzBottoCli).place(x=20, y=20)

root.mainloop()

#SECOND PROGRAM
from tkinter import *
def funzBottoCli():fine_cli_ins.destroy()

fine_cli_ins = Tk()

fine_cli_ins.title("Inserimento Anagrafica Clienti")

fine_cli_ins.geometry('640x480+400+150')

form1 = Frame(fine_cli_ins, bg='red',width=640, height=50, relief='raised',        
border=3).pack() 

label1 = Label(fine_cli_ins, text=(" INSERIMENTO CLIENTI "), fg=('red'),   
bg=('gray'),   
font=('arial',16,'bold'), relief='raised').place(x=200, y=10)

bottonCli = Button(fine_cli_ins, text="      Chiusura finestra      ", fg=('red'),   
font=('arial',10,'bold'), relief='raised', command=funzBottoCli).place(x=260, y=400)

fine_cli_ins.mainloop()
Community
  • 1
  • 1
  • see this link for more information [her](http://stackoverflow.com/questions/8009176/function-to-close-the-window-in-tkinter) – Walid Bousseta Apr 28 '17 at 09:44

1 Answers1

1

If you want to open and close multiple windows. the proper way to do it is to create a single instance of Tk and then one or more instances of Toplevel. Your program should then exit when the instance of Tk is destroyed.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685