mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Bruce Sherwood RFE/Patch
SF 661318 Adds autosave capability to IDLE and IDLE configuration dialog. User can Run/F5 without explicit save dialog. The default is to require the user to confirm the save. M ScriptBinding.py M config-main.def M configDialog.py
This commit is contained in:
parent
4ee6eef22f
commit
6c638b6755
3 changed files with 60 additions and 23 deletions
|
@ -24,6 +24,8 @@ import tokenize
|
|||
import tkMessageBox
|
||||
import PyShell
|
||||
|
||||
from configHandler import idleConf
|
||||
|
||||
IDENTCHARS = string.ascii_letters + string.digits + "_"
|
||||
|
||||
indent_message = """Error: Inconsistent indentation detected!
|
||||
|
@ -144,27 +146,37 @@ class ScriptBinding:
|
|||
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 the user has configured IDLE for Autosave, the file will be
|
||||
silently saved if it already exists and is dirty.
|
||||
|
||||
"""
|
||||
filename = self.editwin.io.filename
|
||||
if not self.editwin.get_saved():
|
||||
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,
|
||||
default=tkMessageBox.OK,
|
||||
master=self.editwin.text)
|
||||
reply = mb.show()
|
||||
if reply == "ok":
|
||||
autosave = idleConf.GetOption('main', 'General',
|
||||
'autosave', type='bool')
|
||||
if autosave and filename:
|
||||
self.editwin.io.save(None)
|
||||
else:
|
||||
return None
|
||||
# filename is None if file doesn't exist
|
||||
filename = self.editwin.io.filename
|
||||
self.editwin.text.focus_set()
|
||||
reply = self.ask_save_dialog()
|
||||
self.editwin.text.focus_set()
|
||||
if reply == "ok":
|
||||
self.editwin.io.save(None)
|
||||
filename = self.editwin.io.filename
|
||||
else:
|
||||
filename = None
|
||||
return filename
|
||||
|
||||
def ask_save_dialog(self):
|
||||
msg = "Source Must Be Saved\n" + 5*' ' + "OK to Save?"
|
||||
mb = tkMessageBox.Message(title="Save Before Run or Check",
|
||||
message=msg,
|
||||
icon=tkMessageBox.QUESTION,
|
||||
type=tkMessageBox.OKCANCEL,
|
||||
default=tkMessageBox.OK,
|
||||
master=self.editwin.text)
|
||||
return mb.show()
|
||||
|
||||
def errorbox(self, title, message):
|
||||
# XXX This should really be a function of EditorWindow...
|
||||
tkMessageBox.showerror(title, message, master=self.editwin.text)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue