Skip to content

Commit e5ef47e

Browse files
gh-159517: Do not use ::tk::unsupported::MacWindowStyle in IDLE on Tk 9.1 (GH-159527)
Tk 9.1 no longer provides this command. Use "wm attributes -stylemask docmodal" instead, as Tk itself does for its balloon window. The calls were silently ignored, so the completion list and the call tip could grab the focus on macOS.
1 parent 010bebb commit e5ef47e

3 files changed

Lines changed: 18 additions & 13 deletions

File tree

‎Lib/idlelib/autocomplete_w.py‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,14 @@ def show_window(self, comp_lists, index, complete, mode, userWantsWin):
185185
self.autocompletewindow = acw = Toplevel(self.widget)
186186
acw.withdraw()
187187
acw.wm_overrideredirect(1)
188-
try:
188+
if acw._windowingsystem == 'aqua':
189189
# Prevent grabbing focus on macOS.
190-
acw.tk.call("::tk::unsupported::MacWindowStyle", "style", acw._w,
191-
"help", "noActivates")
192-
except TclError:
193-
pass
190+
if acw.info_patchlevel() >= (9, 1):
191+
acw.update_idletasks()
192+
acw.wm_attributes(stylemask='docmodal')
193+
else:
194+
acw.tk.call('::tk::unsupported::MacWindowStyle', 'style',
195+
acw._w, 'help', 'noActivates')
194196
self.scrollbar = scrollbar = Scrollbar(acw, orient=VERTICAL)
195197
self.listbox = listbox = Listbox(acw, yscrollcommand=scrollbar.set,
196198
exportselection=False)

‎Lib/idlelib/tooltip.py‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@ def showtip(self):
3030
self.tipwindow = tw = Toplevel(self.anchor_widget)
3131
# show no border on the top level window
3232
tw.wm_overrideredirect(1)
33-
try:
34-
# This command is only needed and available on Tk >= 8.4.0 for OSX.
35-
# Without it, call tips intrude on the typing process by grabbing
36-
# the focus.
37-
tw.tk.call("::tk::unsupported::MacWindowStyle", "style", tw._w,
38-
"help", "noActivates")
39-
except TclError:
40-
pass
33+
if tw._windowingsystem == 'aqua':
34+
# Without this, call tips intrude on the typing process by
35+
# grabbing the focus.
36+
if tw.info_patchlevel() >= (9, 1):
37+
tw.update_idletasks()
38+
tw.wm_attributes(stylemask='docmodal')
39+
else:
40+
tw.tk.call('::tk::unsupported::MacWindowStyle', 'style',
41+
tw._w, 'help', 'noActivates')
4142

4243
self.position_window()
4344
self.showcontents()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix the completion list and the call tip grabbing the focus on macOS with
2+
Tcl/Tk 9.1.

0 commit comments

Comments
 (0)