3

I have a tkinter application that has a main window (a Tk) and an additional window (a Toplevel).

I want these windows to group together in the window manager (GNOME Shell). I believe it is necessary to have both the WM_CLASS resource and the WM_CLASS name to be set the same for both windows in order for this to happen.

Setting className on Tk and setting class on Toplevel to my application name seems to change the WM_CLASS name but not the resource, which is why I think they're not grouping. xprop WM_CLASS on the windows shows my chosen name for both entries on the Tk: WM_CLASS(STRING) = "myapp", "Myapp". For the Toplevel, it shows a tk_uid for the first element: WM_CLASS(STRING) = "140626444609872", "Myapp".

I also tried setting the titles of the windows, but it seemed to make no difference.

1 Answer 1

4

You can use the wm group command to group windows together. Some operating systems / window managers may not respect this setting.

In tkinter, you can do this by calling group on the Toplevel instance with the root Tk instance as an argument.

References: wm (tk), wm (tkinter)

Sign up to request clarification or add additional context in comments.

2 Comments

This worked! It turns out the WM_CLASS wasn't what I needed. Please add to your answer that in tkinter, you need to do top_level.group(root), where top_level is the Toplevel, and root is your Tk instance. Thanks!
Edited it myself, actually.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.