summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib
diff options
context:
space:
mode:
authorKurt B. Kaiser <kbk@shore.net>2002-12-19 03:25:34 (GMT)
committerKurt B. Kaiser <kbk@shore.net>2002-12-19 03:25:34 (GMT)
commitd5e1cef92f14636b4c180483d58ae21f6ef9a861 (patch)
tree875a4f42b82439501a34573be3607542c7f39508 /Lib/idlelib
parentdfb808676098bbb711e98ef3388c30c3eb6f0c39 (diff)
downloadcpython-d5e1cef92f14636b4c180483d58ae21f6ef9a861.zip
cpython-d5e1cef92f14636b4c180483d58ae21f6ef9a861.tar.gz
cpython-d5e1cef92f14636b4c180483d58ae21f6ef9a861.tar.bz2
If Edit window has not been saved, offer to save if user tries to Run or
Check the module.
Diffstat (limited to 'Lib/idlelib')
-rw-r--r--Lib/idlelib/ScriptBinding.py35
1 files changed, 21 insertions, 14 deletions
diff --git a/Lib/idlelib/ScriptBinding.py b/Lib/idlelib/ScriptBinding.py
index 1e05f0c..8ab8e7a 100644
--- a/Lib/idlelib/ScriptBinding.py
+++ b/Lib/idlelib/ScriptBinding.py
@@ -141,22 +141,29 @@ class ScriptBinding:
interp.runcode(code)
def getfilename(self):
- # Logic to make sure we have a saved filename
- # XXX Better logic would offer to save!
+ """Get source filename. If not saved, offer to save (or create) file
+
+ The debugger requires a source file. Make sure there is one, and that
+ the current version of the source buffer has been saved. If the user
+ declines to save or cancels the Save As dialog, return None.
+ """
if not self.editwin.get_saved():
- name = (self.editwin.short_title() or
- self.editwin.long_title() or
- "Untitled")
- self.errorbox("Not saved",
- "The buffer for %s is not saved.\n" % name +
- "Please save it first!")
- self.editwin.text.focus_set()
- return
+ msg = """Source Must Be Saved
+ OK to Save?"""
+ mb = tkMessageBox.Message(
+ title="Save Before Run or Check",
+ message=msg,
+ icon=tkMessageBox.QUESTION,
+ type=tkMessageBox.OKCANCEL,
+ master=self.editwin.text)
+ reply = mb.show()
+ if reply == "ok":
+ self.editwin.io.save(None)
+ else:
+ return None
+ # filename is None if file doesn't exist
filename = self.editwin.io.filename
- if not filename:
- self.errorbox("No file name",
- "This window has no file name")
- return
+ self.editwin.text.focus_set()
return filename
def errorbox(self, title, message):