Skip to content
Related Articles

Related Articles

How to create a Splash Screen using Tkinter?

View Discussion
Improve Article
Save Article
  • Difficulty Level : Medium
  • Last Updated : 12 Dec, 2021

Prerequisite: Python GUI – tkinter

Python offers multiple options for developing a 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.

What is a Splash Screen?

A splash screen in tkinter is a tkinter window that disappears after a fixed period and then a particular operation takes place. To Create a splash screen we will use after() and destroy() method.

  • The after() method assigns a time period (as argument) after which a particular operation takes place, that operation is transformed into a function and is passed as an argument in after() method.

Syntax:

root.after(time in millisecond, function name)
  • The destroy() method is used to close the current tkinter window.

Syntax:

root.destroy()

Below is a program that creates two normal Tkinter windows. The smaller window acts as a splash screen but it will not disappear.

Python3




# Import module
from tkinter import *
 
# Create object
splash_root = Tk()
 
# Adjust size
splash_root.geometry("200x200")
 
# Set Label
splash_label = Label(splash_root, text="Splash Screen", font=18)
splash_label.pack()
 
# main window function
def main():
    # Create object
    root = Tk()
 
    # Adjust size
    root.geometry("400x400")
 
 
# Call main function
main()
 
# Execute tkinter
mainloop()

Output:

Main Window

Splash Window

Now we will use the below methods:

  • destroy()
  • after()

To create a splash screen in tkinter.

Below is a program that creates Splash screen in tkinter using after() and destroy() methods.

Python3




# Import module
from tkinter import *
   
# Create object
splash_root = Tk()
   
# Adjust size
splash_root.geometry("200x200")
 
# Set Label
splash_label = Label(splash_root,text="Splash Screen",font=18)
splash_label.pack()
 
# main window function
def main(): 
    # destroy splash window
    splash_root.destroy()
 
    # Execute tkinter
    root = Tk()
       
    # Adjust size
    root.geometry("400x400")
 
# Set Interval
splash_root.after(3000,main)
 
# Execute tkinter
mainloop()

Output:

Here a splash screen is created and it stays for a particular time period and then a next operation takes place i.e a new window is generated.


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!