Skip to content
Related Articles

Related Articles

Improve Article

Hide and Unhide The Window in Tkinter – Python

  • Difficulty Level : Basic
  • Last Updated : 04 Jul, 2021

Prerequisite: Tkinter

Python offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with Tkinter is the fastest and easiest way to create GUI applications. Creating a GUI using Tkinter is an easy task.

In this article, we will discuss how to hide and unhide the window in Tkinter Using Python.

Functions used:

  • Toplevel() is used to launch the second window


toplevel = Toplevel(root, bg, fg, bd, height, width, font, ..)

  • deiconify() is used to show or unhide the window



  • withdraw() is used to hide the window




  • Import module
  • Create a normal window
  • Add buttons to perform hide and unhide actions
  • Now create one more window
  • Execute code



# Import Library
from tkinter import *
# Create Object
root = Tk()
# Set title
root.title("Main Window")
# Set Geometry
# Open New Window
def launch():
    global second
    second = Toplevel()
    second.title("Child Window")
# Show the window
def show():
# Hide the window
def hide():
# Add Buttons
Button(root, text="launch Window", command=launch).pack(pady=10)
Button(root, text="Show", command=show).pack(pady=10)
Button(root, text="Hide", command=hide).pack(pady=10)
# Execute Tkinter


 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

My Personal Notes arrow_drop_up
Recommended Articles
Page :