I am creating a toplevel:
#Loading screen
main = Tk()
loading = Toplevel()
loading.title("Co-worker")
loading.iconbitmap(getcwd()+"/icons/appIcons/windowIcon.ico")
loading.config(bg="#758ECD")
mywidth = 275
imageLoc = f"{getcwd()}/icons/appIcons/appLogo.png"
img = Image.open(imageLoc)
wpercent = (mywidth/float(img.size[0]))
hsize = int((float(img.size[1])*float(wpercent)))
img = img.resize((mywidth,hsize), Image.LANCZOS)
image = ImageTk.PhotoImage(img)
imageLabel = Label(loading, image = image, style = "mainTitle.TLabel")
imageLabel.grid(row=0,column=0)
loadingBar = Progressbar(loading, orient = 'horizontal', mode = 'indeterminate', length = 250, style = "loading.Horizontal.TProgressbar")
loadingBar.grid(row=1,column=0,padx=10,pady=10)
loadingBar.start(10)
main.mainloop()
Then at the end of the code, I destroy the toplevel, once the main window has finished loading. (loading.destroy())
When the code runs, for a short amount of time, the toplevel opens like this, before loading with all of it's widgets correctly.
How can I fix this so that it doesn't flash white first?
For all that are saying this, I just didn't include my imports as the list is very long. I am importing all the widgets directly from tkinter.ttk.
mainloop()call?loading.withdraw()to hide theToplevelwindow thenloading.deiconify()when object creation is complete.