How to hide a Widget?

0

I need to know some way that by clicking on Button "hide" a widget (a Label for example) from my window, being possible to use it later; Using place on the widget that I wish to "hide" (Yes, it NEEDS to be .place ).

OBS: Forgive me for some flaw in creating the question, or lack of clarity; Any questions that have been left by me, I am readily willing to clarify through the comments.

OBS: Use python 3, and for GUI: Tkinter (If you have not made it clear by the tag).

Thank you in advance!

    
asked by anonymous 21.09.2018 / 22:08

1 answer

2

Hello

I started to study the module tkinter yesterday, unfortunately I have this same doubt. But I did that famous 'gambiarra' rsrs:

from tkinter import *

root = Tk()

texto = Label(root, text = 'Exemplo')
texto.place(x=200, y=200)

root.geometry('400x400')
root.mainloop()

Here was the sample code, however, I want to "hide" the label "TEXT".

from tkinter import *

def esconder():
    texto.place(x=3000, y=3000) #Faz a label ir pra um lugar que não aparece na tela


root = Tk()

texto = Label(root, text = 'Exemplo')
botao = Button(root, text = 'Esconder', command = esconder)

texto.place(x=200, y=200)
botao.place(x=200, y=350)


root.geometry('400x400')
root.mainloop()

Explaining the code, def esconder() was given the "order" to play texto to a place where it does not appear on the screen, making it "hidden."

If you want to reuse it in the future, just declare the:

texto.place(x=200, y=200)

That he goes back to where he was. I hope I have helped.

    
22.09.2018 / 04:31