Issue with the Customtkinter window
With the newest update, 5.0 I cannot remember last digit,
When I open the file it opens the window for a split second then automatically closes it. I then uninstalled newest version and installed an older version which works just fine now.
@DRCThala I'm also having this issue when creating a window with customtkinter.CTk() in version 5.0.3.
The window pops up momentarily after init() as the small default window in the top-left of the screen before initialising the rest of the window settings and re-creating itself. Its quite annoying for splash screens.
This is due to the ctk_tk.py script from the customtkinter package in the latest version 5.0.3.
I have tried several things to try and suppress this window appearing for a split second but all solutions are only relevant for tk.Tk() windows, such as:
.attributes('-alpha', 0.0)
.withdraw()
.deiconify()
https://stackoverflow.com/questions/55890931/python-tkinter-small-window-pops-up-momentarily-before-main-window https://stackoverflow.com/questions/15496835/python-tkinter-child-window-issue?rq=1
The workaround I've found is to create your main window as a regular tkinter window with tkinter.Tk(), then use the customtkinter dependencies inside a frame with customtkinter.CTkFrame()
Example:
import tkinter as tk
import customtkinter as ct
class AppFrame(ct.CTkFrame):
def __init__(self):
super(AppFrame, self).__init__(main_window)
main_window.geometry('250x100+600+200')
main_window.title("Main Window")
self.button = ct.CTkButton(self, text="Button!", command=self.button_command, fg_color="#000000", corner_radius=5, hover_color="#27af42", text_color="#FFFFFF", font=("Tahoma",11), width=15)
self.button.pack(pady=8, padx=8)
self.pack(pady=25)
def button_command(self):
print('hello world')
if __name__ == '__main__':
main_window = tk.Tk()
app_frame = AppFrame()
main_window.mainloop()
Here, main_window is defined as a tk.Tk() window instead of a ct.CTk() window. You still get to use all the customtkinter methods as they're instead the CTkFrame(), which is inside the main_window, and you'll notice the initial popup window doesn't appear.