If Edit window has not been saved, offer to save if user tries to Run or
Check the module.
This commit is contained in:
parent
dfb8086760
commit
d5e1cef92f
|
@ -141,22 +141,29 @@ class ScriptBinding:
|
||||||
interp.runcode(code)
|
interp.runcode(code)
|
||||||
|
|
||||||
def getfilename(self):
|
def getfilename(self):
|
||||||
# Logic to make sure we have a saved filename
|
"""Get source filename. If not saved, offer to save (or create) file
|
||||||
# XXX Better logic would offer to save!
|
|
||||||
|
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():
|
if not self.editwin.get_saved():
|
||||||
name = (self.editwin.short_title() or
|
msg = """Source Must Be Saved
|
||||||
self.editwin.long_title() or
|
OK to Save?"""
|
||||||
"Untitled")
|
mb = tkMessageBox.Message(
|
||||||
self.errorbox("Not saved",
|
title="Save Before Run or Check",
|
||||||
"The buffer for %s is not saved.\n" % name +
|
message=msg,
|
||||||
"Please save it first!")
|
icon=tkMessageBox.QUESTION,
|
||||||
self.editwin.text.focus_set()
|
type=tkMessageBox.OKCANCEL,
|
||||||
return
|
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
|
filename = self.editwin.io.filename
|
||||||
if not filename:
|
self.editwin.text.focus_set()
|
||||||
self.errorbox("No file name",
|
|
||||||
"This window has no file name")
|
|
||||||
return
|
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
def errorbox(self, title, message):
|
def errorbox(self, title, message):
|
||||||
|
|
Loading…
Reference in New Issue