How to Hide, Recover and Delete Tkinter Widgets?
Tkinter is a Python Package for creating GUI(Graphical User Interface) applications. Tkinter provides us with a variety of common GUI elements which we can use to build out interfaces — such as buttons, label, frame, message, menu, and various kind of entry fields and display areas. We call these elements of Widgets.
Widget is an element of Graphical User Interface (GUI) that illustrates information so that a user can interact with the OS. In Tkinter, Widgets are objects; instances of classes that represent buttons, frames, and so on.
In this article, we will demonstrate how to Hide, Recover, and Delete the Tkinter widgets, by using the various elements of widgets like buttons, labels, frames etc.
We could hide the Tkinter widgets by calling pack_forget() method to make the widgets invisible. We need to call the pack() method again to pack the widget to make it visible, or to recover it. We can also delete Tkinter widgets permanently by calling the destroy() method in this section.
Example 1: Hide and Recover the button in Tkinter using forget_pack() and pack() method.
Widget can be any valid widget which is visible.
Example 2: Hide and Recover the Label in Tkinter using forget_pack() and pack() method.
Example 3: Delete Tkinter widgets permanently by calling the destroy() method. We can use this method with any of the available widgets as well as with the main tkinter window.
Please Login to comment...