Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb44372b

Browse files
gh-112898: Remove the false "Cancel" button in the "Save On Close" dialog
On macOS, when it is asked just before quiting the application, the userhas no option to cancel quiting.
1 parente0fb700 commitb44372b

File tree

5 files changed

+20
-11
lines changed

5 files changed

+20
-11
lines changed

‎Lib/idlelib/editor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,18 +1110,18 @@ def close_event(self, event):
11101110
self.close()
11111111
return"break"
11121112

1113-
defmaybesave(self):
1113+
defmaybesave(self,force=False):
11141114
ifself.io:
11151115
ifnotself.get_saved():
11161116
ifself.top.state()!='normal':
11171117
self.top.deiconify()
11181118
self.top.lower()
11191119
self.top.lift()
1120-
returnself.io.maybesave()
1120+
returnself.io.maybesave(force=force)
11211121

1122-
defclose(self):
1122+
defclose(self,force=False):
11231123
try:
1124-
reply=self.maybesave()
1124+
reply=self.maybesave(force=force)
11251125
ifstr(reply)!="cancel":
11261126
self._close()
11271127
returnreply

‎Lib/idlelib/filelist.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,16 @@ def gotofileline(self, filename, lineno=None):
4949
defnew(self,filename=None):
5050
returnself.EditorWindow(self,filename)
5151

52-
defclose_all_callback(self,*args,**kwds):
52+
defclose_all_callback(self,*args,force=False,**kwds):
5353
foreditinlist(self.inversedict):
54-
reply=edit.close()
54+
reply=edit.close(force=force)
5555
ifreply=="cancel":
5656
break
5757
return"break"
5858

59+
defclose_all_force_callback(self,*args,**kwds):
60+
returnself.close_all_callback(*args,force=True,**kwds)
61+
5962
defunregister_maybe_terminate(self,edit):
6063
try:
6164
key=self.inversedict[edit]

‎Lib/idlelib/iomenu.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def loadfile(self, filename):
179179
self.updaterecentfileslist(filename)
180180
returnTrue
181181

182-
defmaybesave(self):
182+
defmaybesave(self,force=False):
183183
"""Return 'yes', 'no', 'cancel' as appropriate.
184184
185185
Tkinter messagebox.askyesnocancel converts these tk responses
@@ -190,15 +190,19 @@ def maybesave(self):
190190
message= ("Do you want to save "
191191
f"{self.filenameor'this untitled document'}"
192192
" before closing?")
193-
confirm=messagebox.askyesnocancel(
193+
makemsgbox=messagebox.askyesnoifforceelsemessagebox.askyesnocancel
194+
confirm=makemsgbox(
194195
title="Save On Close",
195196
message=message,
196197
default=messagebox.YES,
197198
parent=self.text)
199+
reply="no"ifforceelse"cancel"
198200
ifconfirm:
199201
self.save(None)
200-
reply="yes"ifself.get_saved()else"cancel"
201-
else:reply="cancel"ifconfirmisNoneelse"no"
202+
ifself.get_saved():
203+
reply="yes"
204+
elifconfirmisnotNone:
205+
reply="no"
202206
self.text.focus_set()
203207
returnreply
204208

‎Lib/idlelib/macosx.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def help_dialog(event=None):
221221
# The binding above doesn't reliably work on all versions of Tk
222222
# on macOS. Adding command definition below does seem to do the
223223
# right thing for now.
224-
root.createcommand('::tk::mac::Quit',flist.close_all_callback)
224+
root.createcommand('::tk::mac::Quit',flist.close_all_force_callback)
225225

226226
ifisCarbonTk():
227227
# for Carbon AquaTk, replace the default Tk apple menu
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Remove the "Cancel" button in the "Save On Close" message box on macOS when
2+
the user has no option to cancel quiting.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp