]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-66331: Set correct WM_CLASS on X11 for IDLE windows (#152733)
authorSerhiy Storchaka <storchaka@gmail.com>
Wed, 1 Jul 2026 15:10:49 +0000 (18:10 +0300)
committerGitHub <noreply@github.com>
Wed, 1 Jul 2026 15:10:49 +0000 (11:10 -0400)
Set the WM_CLASS of IDLE's long-lived windows (window-list windows and
the stack viewers) to "Idle" instead of the default "Toplevel", so that
window managers group and label them correctly.

Lib/idlelib/idle_test/test_stackviewer.py
Lib/idlelib/idle_test/test_window.py
Lib/idlelib/pyshell.py
Lib/idlelib/stackviewer.py
Lib/idlelib/window.py
Misc/NEWS.d/next/IDLE/2026-07-01-00-00-00.gh-issue-66331.wMcLaS.rst [new file with mode: 0644]

index 2434d38e4ffe83e5e9d4bf1e39b498ba8c99b3bc..341f158031d5f42ce45bcf903d4928e9c2ad5c57 100644 (file)
@@ -35,6 +35,8 @@ class StackBrowserTest(unittest.TestCase):
         isi(stackviewer.sc, ScrolledCanvas)
         isi(stackviewer.item, stackviewer.StackTreeItem)
         isi(stackviewer.node, TreeNode)
+        top = stackviewer.sc.frame.winfo_toplevel()
+        self.assertEqual(top.winfo_class(), 'Idle')
 
 
 if __name__ == '__main__':
index 9b56d321a407d687c6b712dd91e1b1403c8951ec..d8a77817205dc39353c91ed2580a8fd85ba8f947 100644 (file)
@@ -39,6 +39,11 @@ class ListedToplevelTest(unittest.TestCase):
         win = window.ListedToplevel(self.root)
         self.assertIn(win, window.registry)
         self.assertEqual(win.focused_widget, win)
+        self.assertEqual(win.winfo_class(), 'Idle')
+
+    def test_init_class_override(self):
+        win = window.ListedToplevel(self.root, class_='Other')
+        self.assertEqual(win.winfo_class(), 'Other')
 
 
 if __name__ == '__main__':
index 439f98170292b07f261de1af069ca9bc1cab8639..f117f0bfb52f2a3163ad46be79403fbe6bf3c6b1 100755 (executable)
@@ -644,7 +644,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
             return
         item = debugobj_r.StubObjectTreeItem(self.rpcclt, oid)
         from idlelib.tree import ScrolledCanvas, TreeNode
-        top = Toplevel(self.tkconsole.root)
+        top = Toplevel(self.tkconsole.root, class_='Idle')
         theme = idleConf.CurrentTheme()
         background = idleConf.GetHighlight(theme, 'normal')['background']
         sc = ScrolledCanvas(top, bg=background, highlightthickness=0)
index 95042d4debdc03b77cdeff58a84819db6403b0e9..268e2f1daeb98cc4aa1e5bf59dce9c8763110e22 100644 (file)
@@ -11,7 +11,7 @@ from idlelib.tree import TreeNode, TreeItem, ScrolledCanvas
 def StackBrowser(root, exc, flist=None, top=None):
     global sc, item, node  # For testing.
     if top is None:
-        top = tk.Toplevel(root)
+        top = tk.Toplevel(root, class_='Idle')
     sc = ScrolledCanvas(top, bg="white", highlightthickness=0)
     sc.frame.pack(expand=1, fill="both")
     item = StackTreeItem(exc, flist)
index 460d5b67948dde2e1eee32fa548fdd289e3512de..a41d69927dcdd57d8f3715fcdfaa3b6372bdbb38 100644 (file)
@@ -61,6 +61,10 @@ unregister_callback = registry.unregister_callback
 class ListedToplevel(Toplevel):
 
     def __init__(self, master, **kw):
+        # Set the WM_CLASS property so that X11 window managers group and
+        # label IDLE's windows under 'Idle' instead of the default
+        # 'Toplevel' (gh-66331).  It matches the class name passed to Tk().
+        kw.setdefault('class_', 'Idle')
         Toplevel.__init__(self, master, kw)
         registry.add(self)
         self.focused_widget = self
diff --git a/Misc/NEWS.d/next/IDLE/2026-07-01-00-00-00.gh-issue-66331.wMcLaS.rst b/Misc/NEWS.d/next/IDLE/2026-07-01-00-00-00.gh-issue-66331.wMcLaS.rst
new file mode 100644 (file)
index 0000000..e00e7c7
--- /dev/null
@@ -0,0 +1,3 @@
+Set the ``WM_CLASS`` window property of IDLE's windows to ``Idle`` on X11,
+so that window managers group and label them correctly instead of using the
+default ``Toplevel``.