Tạo splash screen Tkinter theo các bước:
- Tạo splash screen với label.
- Bỏ viền bằng
overrideredirect(True). - Tạo hàm main window hiện sau splash.
- Dùng
after(ms, func)đặt thời gian hiển thị splash.
Ví dụ
# Import tkinter
from tkinter import *
splash_win = Tk()
splash_win.title("Splash Screen Example")
splash_win.geometry("700x200")
splash_win.overrideredirect(True) # Bỏ viền
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")
Label(win, text="Main Window", font=('Helvetica', 25), fg="red").pack(pady=20)
# Splash hiển thị 5000ms (5 giây)
splash_win.after(5000, mainWin)
mainloop()Kết quả
Chạy code hiển thị splash screen 5 giây, sau đó main window.

