CustomTkinter icon indicating copy to clipboard operation
CustomTkinter copied to clipboard

Small window pops up before main window

Open ExodusHour opened this issue 2 years ago • 3 comments

A small window pops up just before the main window is shown. I don't have this problem with regular Tkinter, so not sure what's causing it. I've tried with the example files and it happens with those as well. I'm on the most recent version, have tried reinstalling, tried on a different PC, and tried in a venv and have had no luck. Found this Stack Overflow answer but it doesn't seem to apply here as all I have is a small base app. https://stackoverflow.com/questions/55890931/python-tkinter-small-window-pops-up-momentarily-before-main-window. Any help would be great, thanks

Edit: Seems to be a problem with 5.0.3, I installed 5.0.2 and I don't have this issue anymore.

ctk.webm

ExodusHour avatar Dec 28 '22 05:12 ExodusHour

Actually the Default Icon of the CustomTkinter is causing this issue for now we can solve this by: Editing the init.py file in tkinter folder of Python, just add # in these Lines:

before: prev

after: new

Hope this work for you as it is working for me I know this is not good method but if you can wait for Customtkinter new update to resolve this issue you can use this till then!

harshnagar avatar Dec 31 '22 10:12 harshnagar

Thanks, this was a good workaround!

thomasrice avatar Jan 05 '23 00:01 thomasrice

@ExodusHour I've also been encountering this in the latest version 5.0.3.

I'm not sure exactly where the problem is but I know its when creating a customtkinter.CTk() window, which is inside the ctk_tk.py script of the the customtkinter package.

I found some of the issues you described related to wm_iconbitmap() in other questions but couldn't apply this to customtkinter windows.

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

A workaround is to create your main window as a regular tkinter.Tk() window instead of a customtkinter window, and then create a customtkinter.CTkFrame() inside the main window so you can still use all the customtkinter methods and dependencies.

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()

lachesis17 avatar Jan 11 '23 11:01 lachesis17

Fixed now with version 5.0.4.

TomSchimansky avatar Jan 21 '23 12:01 TomSchimansky