File tree 1 file changed +11
-10
lines changed 1 file changed +11
-10
lines changed Original file line number Diff line number Diff line change 7
7
8
8
from tkinter import filedialog
9
9
from tkinter import messagebox
10
- from tkinter .simpledialog import askstring
10
+ from tkinter .simpledialog import askstring # loadfile encoding.
11
11
12
12
from idlelib .config import idleConf
13
13
from idlelib .util import py_extensions
@@ -180,24 +180,25 @@ def loadfile(self, filename):
180
180
return True
181
181
182
182
def maybesave (self ):
183
+ """Return 'yes', 'no', 'cancel' as appropriate.
184
+
185
+ Tkinter messagebox.askyesnocancel converts these tk responses
186
+ to True, False, None. Convert back, as now expected elsewhere.
187
+ """
183
188
if self .get_saved ():
184
189
return "yes"
185
- message = "Do you want to save %s before closing?" % (
186
- self .filename or "this untitled document" )
190
+ message = ("Do you want to save "
191
+ f"{ self .filename or 'this untitled document' } "
192
+ " before closing?" )
187
193
confirm = messagebox .askyesnocancel (
188
194
title = "Save On Close" ,
189
195
message = message ,
190
196
default = messagebox .YES ,
191
197
parent = self .text )
192
198
if confirm :
193
- reply = "yes"
194
199
self .save (None )
195
- if not self .get_saved ():
196
- reply = "cancel"
197
- elif confirm is None :
198
- reply = "cancel"
199
- else :
200
- reply = "no"
200
+ reply = "yes" if self .get_saved () else "cancel"
201
+ else : reply = "cancel" if confirm is None else "no"
201
202
self .text .focus_set ()
202
203
return reply
203
204
You can’t perform that action at this time.
0 commit comments