I’m using Custom Tkinter to create a splash screen. I wanted to center the splash screen both horizontally and vertically. I tried the following code, but it didn’t work. The splash screen is not exactly centered. I’ve also attached a screenshot. Please check it and let me know your suggestions. Thanks!
splash_screen = CTK.CTk()
splash_screen.overrideredirect(True)
screen_width = splash_screen.winfo_screenwidth()
screen_height = splash_screen.winfo_screenheight()
splash_width = int(0.29 * screen_width)
splash_height = int(0.31 * screen_height)
splash_image = CTK.CTkImage(light_image=Image.open('splash_image.jpg'),size =(splash_width,splash_height))
splash_image_lable = CTK.CTkLabel(splash_screen,image=splash_image,text='')
splash_image_lable.pack(fill=CTK.BOTH, expand=True)
x = (screen_width//2) - (splash_width//2)
y = (screen_height//2) - (splash_height//2)
geometry = f"{int(splash_width)}x{int(splash_height)}+{int(x)}+{int(y)}"
splash_screen.geometry(geometry)
https://i.sstatic.net/nSnfmFAP.png