CustomTkinter
CustomTkinter copied to clipboard
TopLevel issues (iconbitmap & parent)
All top-level windows are set back behind the upper root window and, the icon of top-level is not showing when use iconbitmap() or wm_iconbitmap()
@UserJoo9 Can you please add information about operating system, Python version and CTk version? And maybe also give a minimal example (source code) to reproduce the issue?
@Wolf-SO i use windows OS , python version is 3.10.8, my CTk version is the latest 5.1.2, because i'm using the ScrollableFrame i can't give code example but i can show you sample short video
https://user-images.githubusercontent.com/82382970/217176011-fb5c1945-d2cf-4358-80a1-6ec1d682acbb.mp4
@TomSchimansky can you help sir?
these two issues is fixed on CTk v5.0.2, i tried that and it works fine, but i need CTk v5.1.1 or higher cause i need Scrollable Frame in my project.
You should really strip your project (a copy of it) down to what is necessary to reproduce the problem. That would make it much easier for people here to help you.
(Of course, you can't rule out the possibility of even solving the problem yourself in the course of this process).
I had the same problem in TopLevel. But I managed to change it in three ways:
First, in the folder: Lib/customtkinter/assets/icons I changed the icon image and kept the file name.
Second, in the ctk_toplevel.py file I changed, in lines 45 and 211, the file "CustomTkinter_icon_Windows.ico" by "myicon.ico", but this way myicon.ico appeared in all TopLevels and it was not possible to have different icons for different TopLevel's.
Third, the most effective solution, in the ctk_toplevel.py file, comment lines 41 to 47 and it works "normally".
Please have a look at my comment in issue 1219 https://github.com/TomSchimansky/CustomTkinter/issues/1219#issuecomment-1442929135
To me it seems the reason why any top_level window appears behind the main one might be in the ctk_toplevel.py file. I commented out lines 275-277 and it started to work as expected.
@Miraculum-AZ ,
Did that also resolve the iconbitmap issue?
I use grabset to pull the toplevel window but I've also noticed the desired icon appear briefly but then is replaced with the customtkinter default icon.
@C493 ,
For iconbitmap issue I've seen someone in another thread suggesting to comment out lines 41 to 47 in the same file. To me it did work and I was able to set my custom icon.
Or, if you want to use only one iconbitmap for your project, try going here and replace the image: Python311\Lib\site-packages\customtkinter\assets\icons
You can edit ctk_toplevel.py to fix this problem
You can try
self.after(200, lambda: self.iconbitmap("myprog.ico"))
It helped me, but it has 1 drawback. For a very short time ctk shows default icon, and only then changes it to one you need.
All top-level windows are set back behind the upper root window and, the icon of top-level is not showing when use iconbitmap() or wm_iconbitmap()
Hi, I think you should use the below code to fix your problem
Solution for the icon:
window01.after(250, lambda: window01.iconbitmap("file.ico"))
Solution to bring top-level front:
window01.iconify() window01.after(250, lambda: window01.deiconify())