Buongiorno a tutti. Sono un'appassionato di programmazione e da poco tempo ho iniziato a studiare Python 3.5.2. Sto cercando di fare un piccolo programmino che mi aiuti a gestire meglio i miei voli su x-plane. Si tratta di un programma che (dovrà) calcolare la quantità di carburante necessario ad un volo (programmato). Ho un pc con S.O. windows 7, e per fare ciò uso quanto in oggetto specificato. Purtroppo sono incappato in un problema a cui non so dare una soluzione. Premetto che non sono ancora in grado di programmare usando le classi, pertanto mi devo accontentare di molta semplicità. Dopo aver aperto la mia prima finestra, e passato alla successiva, non riesco più a chiudere quest'ultima (finestra1) per passare alla finestra successiva (finestra2), in quanto l'istruzione finestra1.destroy() non da nessun effetto. Domanda: perchè per chiudere la prima finestra il comando "destroy" funziona e per la successiva no ? Vedi allegato. P.S.: perdonatemi il linguaggio poco tecnico, ma sto cercando di imparare. Grazie a tutti quelli che si prenderanno la briga di rispondere.
from tkinter import* from tkinter import ttk
def xx(): finestra1.destroy() finestra2=Tk() finestra2.title('CALCOLA') finestra2.geometry('500x500+2200+250') contenitore2=Frame(finestra2).pack() frame3=Frame(contenitore2, borderwidth=5, bg='green', relief=RIDGE).pack(fill="both", expand="yes") label=Label(frame3,text='CALCOLA', font=("Helvetica",14), bg='green',fg='black').place(x=185, y=20) separatore=Label(text="==================", bg='green',fg="black").place(x=173, y=45) d=Label(text="DISTANZA IN MN DALL'AEROPORTO DI DESTINAZIONE",bg='green',fg="black",font=("Helvetica",11)).place(x=20, y=100) d1=Label(text="VENTO IN Mh,(se contrario segno -)",bg='green',fg="black", font=("Helvetica",11)).place(x=20, y=120) e=Label(text="DISTANZA IN MN DELL'AEROPORTO ALTERNATO", bg='green',fg="black", font=("Helvetica",11)).place(x=20, y=140) f=Label(text="VELOCITA' DI CROCIERA PREVISTA IN MIGLIA/ORARIE", bg='green',fg="black", font=("Helvetica",11)).place(x=20, y=160) f1=Label(text="CONSUMO MEDIO Kg/ORA DEL TIPO DI AEREO", bg='green',fg="black", font=("Helvetica",11)).place(x=20, y=180) finestra2.mainloop() def istruz(): finestra.destroy() finestra1=Tk() finestra1.title('ISTRUZIONI') finestra1.geometry('500x500+2200+250') contenitore1=Frame(finestra1).pack() frame2=Frame(contenitore1, borderwidth=5, bg='green', relief=RIDGE).pack(fill="both", expand="yes") label=Label(frame2, text='ISTRUZIONI', font=("Helvetica",14), bg='green', fg='black').place(x=185, y=20) f11_2=Label(text=' ==========', font=("Helvetica",14), bg='green', fg='black').place(x=173, y=45) f12=Label(text=" a- Ricorda di inserire i numeri decimali con il punto anzichè la virgola. ",bg='green',fg="black",font=("Helvetica",11)).place(x=20, y=100) f13=Label(text=" b- Il seguente programma, calcola il carburante necessario sia in Kg,",bg='green',fg="black",font=("Helvetica",11)).place(x=20, y=120) f14=Label(text=" che in libbre, utilizzando i seguenti parametri di calcolo:",bg='green',fg="black",font=("Helvetica",11)).place(x=20, y=140) f15=Label(text=" 1- Della distanza dall'aeroporto di destinazione;",bg='green',fg="black",font=("Helvetica",11)).place(x=20, y=160) f16=Label(text=" 2- Della distanza di esso con l'aeroporto alternato;",bg='green',fg="black",font=("Helvetica",11)).place(x=20, y=180) f17=Label(text=" 3- Dei venti contrari o favorevoli alla tratta;",bg='green',fg="black",font=("Helvetica",11)).place(x=20, y=200) f18=Label(text=" 4- Della velocità di crociera prevista;",bg='green',fg="black",font=("Helvetica",11)).place(x=20, y=220) f19=Label(text=" 5- Del consumo orario specificato del tipo di aereo;",bg='green',fg="black",font=("Helvetica",11)).place(x=20, y=240) f20=Label(text=" 6- Della riserva di carburante;",bg='green',fg="black",font=("Helvetica",11)).place(x=20, y=260) f21=Label(text=" 7- Degli imprevisti;",bg='green',fg="black",font=("Helvetica",11)).place(x=20, y=280) f22=Label(text=" 8- Del rullaggio ed Auxilary e PowerUnit;",bg='green',fg="black",font=("Helvetica",11)).place(x=20, y=300) f23=Label(text=" 9- NON tiene conto del Livello di Volo ",bg='green',fg="red",font=("Helvetica",11)).place(x=20, y=320) pulsante3=Button(finestra1,text="ESCI", font=("Helvetica",14), bg='red', fg='black', command=finestra1.destroy).place(x=150, y=400) pulsante4=Button(finestra1,text="Parametri", font=("Helvetica",14), bg='red', fg='black', command=xx).place(x=290, y=400) finestra1.mainloop() finestra=Tk() finestra.title("PROGRAMMA PER IL CALCOLO DEL CARBURANTE") finestra.geometry('500x500+2200+250') contenitore=Frame(finestra).pack() frame1=Frame(contenitore,borderwidth=5, bg='green', relief=RIDGE, width=30).pack(fill="both", expand="yes") label3=Label(frame1, text='BENVENUTO !', font=("Helvetica",16), bg='green', fg='black').place(x=20, y=70) label4=Label(frame1, text='QUESTO PROGRAMMA CALCOLA, CON', font=("Helvetica",14), bg='green', fg='black').place(x=20, y=130) label5=Label(frame1, text='APPROSSIMAZIONE, LA QUANTITA ', font=("Helvetica",14), bg='green', fg='black').place(x=20, y=160) label6=Label(frame1, text='DI CARBURANTE NECESSARIA PER ', font=("Helvetica",14), bg='green', fg='black').place(x=20, y=190) label7=Label(frame1, text='EFFETTUARE UN VOLO DA.....A...,', font=("Helvetica",14), bg='green', fg='black').place(x=20, y=220) label8=Label(frame1, text='E QUELLO EFFETTIVO DA IMBARCARE', font=("Helvetica",14), bg='green', fg='black').place(x=20, y=250) label9=Label(frame1, text='SUL VELIVOLO. ', font=("Helvetica",14), bg='green', fg='black').place(x=20, y=280) pulsante1=Button(finestra,text="ESCI", font=("Helvetica",14), bg='red', fg='black', command=finestra.destroy).place(x=100, y=400) pulsante2=Button(text="OK, PROSEGUI", font=("Helvetica",14), bg='red', fg='black', command=istruz).place(x=250, y=400) finestra.mainloop()
_______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python