Let us suppose that we want to create a splash screen using tkinter. To create a splash screen, we will follow the steps given below −
Create a splash screen with some labels in it.
Make the splash screen borderless using the overrideredirect method.
Create a function for the main window which will appear for a time just after the splash screen.
Now using the after method, we can define the time for which the main window will appear.
#Importing the tkinter library from tkinter import * #Create an instance of tkinter frame splash_win= Tk() #Set the title of the window splash_win.title("Splash Screen Example") #Define the size of the window or frame splash_win.geometry("700x200") #Remove border of the splash Window splash_win.overrideredirect(True) #Define the label of the window splash_label= Label(splash_win, text= "Hello World!", fg= "green", font= ('Times New Roman', 40)).pack(pady=20) def mainWin(): splash_win.destroy() win= Tk() win.title("Main Window") win.geometry("700x200") win_label= Label(win, text= "Main Window", font= ('Helvetica', 25), fg= "red").pack(pady=20) #Splash Window Timer splash_win.after(5000, mainWin) mainloop()
Running the above code will generate the output and will show the splash screen and after some time, the main window.