CustomTkinter icon indicating copy to clipboard operation
CustomTkinter copied to clipboard

TopLevel issues (iconbitmap & parent)

Open UserJoo9 opened this issue 2 years ago • 13 comments

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 avatar Feb 07 '23 03:02 UserJoo9

@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 avatar Feb 07 '23 07:02 Wolf-SO

@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

UserJoo9 avatar Feb 07 '23 07:02 UserJoo9

@TomSchimansky can you help sir?

UserJoo9 avatar Feb 08 '23 02:02 UserJoo9

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.

UserJoo9 avatar Feb 08 '23 12:02 UserJoo9

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

Wolf-SO avatar Feb 08 '23 12:02 Wolf-SO

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".

saieat avatar Feb 17 '23 22:02 saieat

Please have a look at my comment in issue 1219 https://github.com/TomSchimansky/CustomTkinter/issues/1219#issuecomment-1442929135

RunsOnRum avatar Feb 25 '23 04:02 RunsOnRum

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 avatar Jul 27 '23 12:07 Miraculum-AZ

@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 avatar Jul 27 '23 15:07 C493

@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

Miraculum-AZ avatar Jul 27 '23 16:07 Miraculum-AZ

You can edit ctk_toplevel.py to fix this problem

ghost avatar Nov 11 '23 18:11 ghost

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.

Naz2204 avatar Nov 15 '23 21:11 Naz2204

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

Yuniek avatar Apr 02 '24 08:04 Yuniek