Python Forum

Full Version: Issue on tkinter with buttons
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, Here's my problem I want that when You press "button3" after having pressed"button", it also destroys label6 from" do_it" function.


    def do_it():
        F= calcul_salarie(i.get(), k.get(), revenu_moyen.get(), trimestre_cotisés.get(), enfants.get())
        G=F/12
        RA=int(F/12)
        A= str(i.get())+", Ta pension de retraite sera de: "+str(F)+"€ par an, soit de :"+str(RA)+"€ par mois"

        button.destroy()
        label6= Label(Appli,text=A,font=("arial",15,"bold"), fg="black")
        label6.place(x=20, y=100)
        
        





    def return_page():
        button3.destroy()
        page_principale()
        label1.destroy()
        entry_box1.destroy()
        label2.destroy()
        entry_box2.destroy()
        label3.destroy()
        entry_box3.destroy()
        label4.destroy()
        entry_box4.destroy()
        label5.destroy()
        entry_box5.destroy()
        label6.destroy()

    button= Button(Appli, text="Calulate", width="18", height="9",command=do_it,bg="white")
    button.place(x=500, y=470)

    button3= Button(Appli, text="Initial page", width="18", height="9",command=return_page,bg="white")
    button3.place(x=50,y=200)

    
Hi!
label6 is a local variable and cannot be seen in another function. Do it at the beginning of the code. If you do not want it to be immediately visible, then do not use the label6.place () method.