]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.9] bpo-43655: Tkinter and IDLE dialog windows are now recognized as dialogs by...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 25 Apr 2021 11:19:52 +0000 (04:19 -0700)
committerGitHub <noreply@github.com>
Sun, 25 Apr 2021 11:19:52 +0000 (14:19 +0300)
(cherry picked from commit 3bb3fb3be09d472a43cdc3d9d9578bd49f3dfb8c)
(cherry picked from commit 9a165399aec930f27639dd173426ccc33586662b)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Lib/idlelib/config_key.py
Lib/idlelib/query.py
Lib/idlelib/searchbase.py
Lib/tkinter/filedialog.py
Lib/tkinter/simpledialog.py
Misc/NEWS.d/next/IDLE/2021-04-04-20-52-07.bpo-43655.HSyaKH.rst [new file with mode: 0644]
Misc/NEWS.d/next/Library/2021-04-04-20-51-19.bpo-43655.LwGy8R.rst [new file with mode: 0644]

index 7510aa9f3d87864a0974b4db91f5504c1249a999..9ca3a156f4b97f1c2d2a40234a5acc163a433750 100644 (file)
@@ -4,6 +4,7 @@ Dialog for building Tkinter accelerator key bindings
 from tkinter import Toplevel, Listbox, StringVar, TclError
 from tkinter.ttk import Frame, Button, Checkbutton, Entry, Label, Scrollbar
 from tkinter import messagebox
+from tkinter.simpledialog import _setup_dialog
 import string
 import sys
 
@@ -63,6 +64,7 @@ class GetKeysDialog(Toplevel):
         self.resizable(height=False, width=False)
         self.title(title)
         self.transient(parent)
+        _setup_dialog(self)
         self.grab_set()
         self.protocol("WM_DELETE_WINDOW", self.cancel)
         self.parent = parent
index 015fc7ade459dbde432759a1b66b19ab32e5f6b5..fefa5aac1b7f58a78931339719817d22a4ae35b0 100644 (file)
@@ -28,6 +28,7 @@ from tkinter import Toplevel, StringVar, BooleanVar, W, E, S
 from tkinter.ttk import Frame, Button, Entry, Label, Checkbutton
 from tkinter import filedialog
 from tkinter.font import Font
+from tkinter.simpledialog import _setup_dialog
 
 class Query(Toplevel):
     """Base class for getting verified answer from a user.
@@ -60,13 +61,8 @@ class Query(Toplevel):
         if not _utest:  # Otherwise fail when directly run unittest.
             self.grab_set()
 
-        windowingsystem = self.tk.call('tk', 'windowingsystem')
-        if windowingsystem == 'aqua':
-            try:
-                self.tk.call('::tk::unsupported::MacWindowStyle', 'style',
-                             self._w, 'moveableModal', '')
-            except:
-                pass
+        _setup_dialog(self)
+        if self._windowingsystem == 'aqua':
             self.bind("<Command-.>", self.cancel)
         self.bind('<Key-Escape>', self.cancel)
         self.protocol("WM_DELETE_WINDOW", self.cancel)
index fbef87aa2d3d04c1865b28252324b9e39d478947..64ed50c7364be394c08df04c94c737f738f2f8b6 100644 (file)
@@ -2,6 +2,7 @@
 
 from tkinter import Toplevel
 from tkinter.ttk import Frame, Entry, Label, Button, Checkbutton, Radiobutton
+from tkinter.simpledialog import _setup_dialog
 
 
 class SearchDialogBase:
@@ -83,6 +84,7 @@ class SearchDialogBase:
         top.protocol("WM_DELETE_WINDOW", self.close)
         top.wm_title(self.title)
         top.wm_iconname(self.icon)
+        _setup_dialog(top)
         self.top = top
         self.frame = Frame(top, padding="5px")
         self.frame.grid(sticky="nwes")
index 88d23476fde2845481537843ad59c96813ee8796..09ff1cb1cb63d38d27bf2593fca7c394a3dbdd71 100644 (file)
@@ -15,6 +15,7 @@ These interfaces were written by Fredrik Lundh, May 1997.
 from tkinter import *
 from tkinter.dialog import Dialog
 from tkinter import commondialog
+from tkinter.simpledialog import _setup_dialog
 
 import os
 import fnmatch
@@ -56,6 +57,7 @@ class FileDialog:
         self.top = Toplevel(master)
         self.top.title(title)
         self.top.iconname(title)
+        _setup_dialog(self.top)
 
         self.botframe = Frame(self.top)
         self.botframe.pack(side=BOTTOM, fill=X)
index b882d47c961bdbf889d67273e12b5969a86a639c..802202560af529c1221e0e284685f23d07a2c092 100644 (file)
@@ -39,6 +39,9 @@ class SimpleDialog:
         if title:
             self.root.title(title)
             self.root.iconname(title)
+
+        _setup_dialog(self.root)
+
         self.message = Message(self.root, text=text, aspect=400)
         self.message.pack(expand=1, fill=BOTH)
         self.frame = Frame(self.root)
@@ -142,6 +145,8 @@ class Dialog(Toplevel):
         if title:
             self.title(title)
 
+        _setup_dialog(self)
+
         self.parent = parent
 
         self.result = None
@@ -251,6 +256,13 @@ class Dialog(Toplevel):
         pass # override
 
 
+def _setup_dialog(w):
+    if w._windowingsystem == "aqua":
+        w.tk.call("::tk::unsupported::MacWindowStyle", "style",
+                  w, "moveableModal", "")
+    elif w._windowingsystem == "x11":
+        w.wm_attributes("-type", "dialog")
+
 # --------------------------------------------------------------------
 # convenience dialogues
 
diff --git a/Misc/NEWS.d/next/IDLE/2021-04-04-20-52-07.bpo-43655.HSyaKH.rst b/Misc/NEWS.d/next/IDLE/2021-04-04-20-52-07.bpo-43655.HSyaKH.rst
new file mode 100644 (file)
index 0000000..105ec92
--- /dev/null
@@ -0,0 +1,2 @@
+IDLE dialog windows are now recognized as dialogs by window managers on
+macOS and X Window.
diff --git a/Misc/NEWS.d/next/Library/2021-04-04-20-51-19.bpo-43655.LwGy8R.rst b/Misc/NEWS.d/next/Library/2021-04-04-20-51-19.bpo-43655.LwGy8R.rst
new file mode 100644 (file)
index 0000000..7916d22
--- /dev/null
@@ -0,0 +1,2 @@
+:mod:`tkinter` dialog windows are now recognized as dialogs by window
+managers on macOS and X Window.