Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Place_forget() method using Tkinter in Python

  • Last Updated : 01 Aug, 2020

To hide or forget a widget from the parent widget or screen in tkinter, the place_forget() method is used on that widget based on place geometry management.

Syntax: widget.place_forget() 

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

Parameter: None
Return: None

Below is the implementation : 


# Imports everything from tkinter
# and ttk module
from tkinter import *
from tkinter.ttk import *
# toplevel window
root = Tk()
# setting window size
# label widget
label = Label(root, text="LABEL")
# place in the window, y=5)
# button widgets
# In command attribute of Button,
# place_forget() method is passed
# in the lambda function to temporarily
# hide the label
b1 = Button(root, text = "hide text",
            command = lambda: label.place_forget()) = 0.3, y = 30)
# the label is placed again
b2 = Button(root, text = "retrieve text",
            command = lambda:
              relx = 0.4)) = 0.3, y = 50)
# Start the GUI



After hiding:


After retrieving:


Note: There are other methods pack_forget() and grid_forget() that work the same way as forget_pack() and forget_grid() .

My Personal Notes arrow_drop_up
Recommended Articles
Page :