TomSchimansky / CustomTkinter

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

How to allow windows to overlap though it is topmost window like widgets? #2377

Open Sayad-Uddin-Tahsin opened 5 months ago

Sayad-Uddin-Tahsin commented 5 months ago

I want to create a Windows 10 widget that stays on the desktop but doesn't overlap with other windows or disappear when I press Win + D or click the Desktop button. Basically, I want it to always be visible on the desktop, even if other applications are running but not overlap on any other Application's Interface. How can I do so?

Akascape commented 5 months ago

@Sayad-Uddin-Tahsin Use this: root.attributes("-topmost", True)

Sayad-Uddin-Tahsin commented 5 months ago

@Sayad-Uddin-Tahsin Use this: root.attributes("-topmost", True)

but it makes my window to overlap other windows! I don’t want so, but I want it to not disappeare once desktop button is clicked! It will always there in the Desktop ( All minimized). I hope you understood

Akascape commented 5 months ago

@Sayad-Uddin-Tahsin Then simply use the overrideredirect method

root.overrideredirect()

Sayad-Uddin-Tahsin commented 5 months ago

@Sayad-Uddin-Tahsin Then simply use the overrideredirect method

root.overrideredirect()

Using root.overrideredirect() also seems hides the windows on Desktop Button Press! Doesn’t it hide the top control bars? I am using it currently...

Sayad-Uddin-Tahsin commented 5 months ago

@Akascape Do you know any way to just detect the Desktop Button Click? so that I can force_focus that on that event which will achieve the effect I'm looking for?

Sayad-Uddin-Tahsin commented 5 months ago

@Akascape Seems using this method:

def unminimize(window: ctk.CTk):
    if not window.winfo_ismapped():
        window.state('withdrawn')
        window.state('normal')
        window.attributes("-topmost", True)
        window.attributes("-topmost", False)

root.bind("<Unmap>", lambda e: root.after(500, lambda: unminimize(root)))

does what I'm looking for but when using overrideredirect(True) doesn't work! Is there any way you know to bypass the issue or any way and achieve what I wanted?