If we want to unmap any widget from the screen or toplevel then
forget() method is used. There are two types of forget method
( similar to
forget() ) and
forget_grid() which are used with
grid() method respectively.
forget_pack() method –
Syntax: widget.forget_pack() widget can be any valid widget which is visible.
Notice the difference in the position of Button 1 before and after forget as well as after retrieval.
forget_grid() method –
Syntax: widget.forget_grid() widget can be any valid widget which is visible.
Note : This method can be used only with
grid() geometry methods.
Notice that the position of Button 1 remains same after forget and retrieval. With
grid_forget() method, you can place it at any grid after retrieval but generally, the original grid is chosen.
- Python | after method in Tkinter
- resizable() method in Tkinter | Python
- Python | grid() method in Tkinter
- maxsize() method in Tkinter | Python
- Python | geometry method in Tkinter
- Python | place() method in Tkinter
- minsize() method in Tkinter | Python
- destroy() method in Tkinter | Python
- Python | pack() method in Tkinter
- iconphoto() method in Tkinter | Python
- Python Tkinter | grid_location() and grid_size() method
- Python Tkinter | Moving objects using Canvas.move() method
- Python GUI - tkinter
- RadioButton in Tkinter | Python
- Different messages in Tkinter | Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.