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
- iconphoto() method in Tkinter | Python
- maxsize() method in Tkinter | Python
- Python | place() method in Tkinter
- Python | pack() method in Tkinter
- destroy() method in Tkinter | Python
- resizable() method in Tkinter | Python
- Python | geometry method in Tkinter
- minsize() method in Tkinter | Python
- Python | grid() method in Tkinter
- 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 email@example.com. 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.