How Does CTKDeb handle StartupWMClass? #1
Replies: 2 comments 1 reply
|
CTkDeb does not need a special option for this; it can emit the standard desktop-entry key. The important part is to make the Tk window class and the desktop entry agree. Create the root window with an explicit import customtkinter as ctk
app = ctk.CTk(className="MyApp")CustomTkinter's current {
"desktopEntry": {
"Name": "My App",
"StartupWMClass": "MyApp"
}
}CTkDeb merges the values in StartupWMClass=MyAppAfter rebuilding and reinstalling the package, verify the real value rather than relying on the window title: xprop WM_CLASSClick the application window. The class (normally the second string) must match |
|
This is a known limitation of Tkinter/CustomTkinter on Linux — the WM_CLASS is hardcoded to Tk by the Tk toolkit itself, and there is no supported Python-side API to change it before the window is mapped. What works in practice: Option A: Override WM_CLASS after window creation (X11 only) import ctypes
# after root/main window is created
root.update_idletasks()
x11 = ctypes.cdll.LoadLibrary(libX11.so.6)
x11.XStoreName(root.winfo_id(), bYourAppName)
# For WM_CLASS you need XSetClassHint — requires a small C helper or python-xlib:With from Xlib import display, X
d = display.Display()
w = d.create_resource_object(window, root.winfo_id())
w.set_wm_class(yourapp, YourApp)
d.sync()Call this after the window is realized but before mapping. It is fragile and X11-only (no Wayland). Option B: Use a custom .desktop file with Option C (recommended): Switch toolkit for the WM_CLASS problem Option D: Wrapper script that renames WM_CLASS post-launch |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
In my desktop file, I am unable to figure out how to change the StartupWMClass value from "Tk". WM_INFO always returns "Tk" so every one of my apps has to be treated as being in the same app group internally, causing issues. I had a conversation about this with the CustomTkinter dev and he wasn't sure how to resolve it and pointed me here.
That conversation: TomSchimansky/CustomTkinter#2859 (comment)
Does anybody in this community know how to handle this case?
Thanks!
All reactions