File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77
88from tkinter import filedialog
99from tkinter import messagebox
10- from tkinter .simpledialog import askstring
10+ from tkinter .simpledialog import askstring # loadfile encoding.
1111
1212from idlelib .config import idleConf
1313from idlelib .util import py_extensions
@@ -180,24 +180,25 @@ def loadfile(self, filename):
180180 return True
181181
182182 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+ """
183188 if self .get_saved ():
184189 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?" )
187193 confirm = messagebox .askyesnocancel (
188194 title = "Save On Close" ,
189195 message = message ,
190196 default = messagebox .YES ,
191197 parent = self .text )
192198 if confirm :
193- reply = "yes"
194199 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"
201202 self .text .focus_set ()
202203 return reply
203204
You can’t perform that action at this time.
0 commit comments