TomSchimansky / CustomTkinter

A modern and customizable python UI-library based on Tkinter
MIT License
10.84k stars 1.02k forks source link

TopLevel window not appearing on top of ctk.CTk() window #2334

Closed Eduard0110 closed 3 months ago

Eduard0110 commented 3 months ago

Not much to describe really, just when creating a TopLevel window (for multiple windows because this is the only way) it does not appear on top of the main window. You have to click on it in oreder for it go on top.

3022-2 commented 3 months ago

my fix is:

lets say the the name of your top level is top

top.after(300, lambda: top.lift()) - this waits 300ms before applying the effect i also ran into issues with displaying icons on toplevel windows the same fix applied

top.after(300, lambda: top.iconbitmap("link to icon"))

import customtkinter

def toplevel(root):
    top = customtkinter.CTkToplevel(root)
    top.after(300, lambda: top.lift())
root = customtkinter.CTk()

btn = customtkinter.CTkButton(master=root, text="goto next level", command=lambda: toplevel(root))
btn.pack()

root.mainloop()
Eduard0110 commented 3 months ago

Thanks! I find it a little weird that the window initially appears on top of other windows and after approximately 300ms it disappears.

3022-2 commented 3 months ago

Thanks! I find it a little weird that the window initially appears on top of other windows and after approximately 300ms it disappears.

honestly idk why it works but it does lol

Karbonite commented 3 months ago

I think it's cleaner using something like:`

top = customtkinter.CTkToplevel(root)
top.attributes('-topmost', True)

No Lambda's and simple!