Python Forum
Issue on tkinter with buttons
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Issue on tkinter with buttons
#1
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)

    
Reply
#2
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Lightbulb [Tkinter] Tkinter Class Import Module Issue AaronCatolico1 6 9,210 Sep-06-2022, 03:37 PM
Last Post: AaronCatolico1
  tkinter toggle buttons not working Nu2Python 26 15,976 Jan-23-2022, 06:49 PM
Last Post: Nu2Python
  Super basic tkinter arduino issue Kurta 3 3,940 Jan-07-2021, 05:22 PM
Last Post: deanhystad
Photo tkinter issue mate 4 4,384 Dec-06-2020, 09:03 PM
Last Post: mate
  Issue in Tkinter with winfo_class() and LabelFrame ReDefendeur 1 4,044 Oct-05-2020, 05:52 AM
Last Post: Jeff900
  [Tkinter] tkinter: after issue edwin6938 1 5,648 Aug-25-2020, 04:37 PM
Last Post: Larz60+
  Tkinter: increasing numbers and Radiobutton issue PeroPuri 1 3,325 Apr-13-2020, 05:48 PM
Last Post: deanhystad
  [Tkinter] tkinter issue with variables carrying over between functions PengEng 1 2,794 Apr-06-2020, 06:13 PM
Last Post: deanhystad
  TkInter Binding Buttons ifigazsi 5 12,592 Apr-06-2020, 08:30 AM
Last Post: ifigazsi
  Need tkinter help with clicking buttons pythonprogrammer 2 4,117 Jan-03-2020, 04:43 AM
Last Post: joe_momma

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020