summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib
diff options
context:
space:
mode:
authorKurt B. Kaiser <kbk@shore.net>2011-05-12 19:25:24 (GMT)
committerKurt B. Kaiser <kbk@shore.net>2011-05-12 19:25:24 (GMT)
commit0a42982316e0e64ac363e157eab43004b09f23c4 (patch)
treeaef019c9356cbef4f6e1ad1e2255275a465ab5cc /Lib/idlelib
parente147806da9b138e53d86f0a2569a107f6a975834 (diff)
downloadcpython-0a42982316e0e64ac363e157eab43004b09f23c4.zip
cpython-0a42982316e0e64ac363e157eab43004b09f23c4.tar.gz
cpython-0a42982316e0e64ac363e157eab43004b09f23c4.tar.bz2
Issue #11896: Save on Close failed despite selecting "Yes" in dialog.
_tkinter.c is returning <class '_tkinter.Tcl_Obj'> sometimes. Don't use tkinter.messagebox.Message - use the helper functions which convert to str.
Diffstat (limited to 'Lib/idlelib')
-rw-r--r--Lib/idlelib/IOBinding.py44
-rw-r--r--Lib/idlelib/NEWS.txt4
-rw-r--r--Lib/idlelib/ScriptBinding.py16
3 files changed, 32 insertions, 32 deletions
diff --git a/Lib/idlelib/IOBinding.py b/Lib/idlelib/IOBinding.py
index 381bb00..3f5d556 100644
--- a/Lib/idlelib/IOBinding.py
+++ b/Lib/idlelib/IOBinding.py
@@ -309,17 +309,20 @@ class IOBinding:
return "yes"
message = "Do you want to save %s before closing?" % (
self.filename or "this untitled document")
- m = tkMessageBox.Message(
- title="Save On Close",
- message=message,
- icon=tkMessageBox.QUESTION,
- type=tkMessageBox.YESNOCANCEL,
- master=self.text)
- reply = m.show()
- if reply == "yes":
+ confirm = tkMessageBox.askyesnocancel(
+ title="Save On Close",
+ message=message,
+ default=tkMessageBox.YES,
+ master=self.text)
+ if confirm:
+ reply = "yes"
self.save(None)
if not self.get_saved():
reply = "cancel"
+ elif confirm is None:
+ reply = "cancel"
+ else:
+ reply = "no"
self.text.focus_set()
return reply
@@ -328,7 +331,7 @@ class IOBinding:
self.save_as(event)
else:
if self.writefile(self.filename):
- self.set_saved(1)
+ self.set_saved(True)
try:
self.editwin.store_file_breaks()
except AttributeError: # may be a PyShell
@@ -420,15 +423,12 @@ class IOBinding:
self.text.insert("end-1c", "\n")
def print_window(self, event):
- m = tkMessageBox.Message(
- title="Print",
- message="Print to Default Printer",
- icon=tkMessageBox.QUESTION,
- type=tkMessageBox.OKCANCEL,
- default=tkMessageBox.OK,
- master=self.text)
- reply = m.show()
- if reply != tkMessageBox.OK:
+ confirm = tkMessageBox.askokcancel(
+ title="Print",
+ message="Print to Default Printer",
+ default=tkMessageBox.OK,
+ master=self.text)
+ if not confirm:
self.text.focus_set()
return "break"
tempfilename = None
@@ -443,8 +443,8 @@ class IOBinding:
if not self.writefile(tempfilename):
os.unlink(tempfilename)
return "break"
- platform=os.name
- printPlatform=1
+ platform = os.name
+ printPlatform = True
if platform == 'posix': #posix platform
command = idleConf.GetOption('main','General',
'print-command-posix')
@@ -452,7 +452,7 @@ class IOBinding:
elif platform == 'nt': #win32 platform
command = idleConf.GetOption('main','General','print-command-win')
else: #no printing for this platform
- printPlatform=0
+ printPlatform = False
if printPlatform: #we can try to print for this platform
command = command % filename
pipe = os.popen(command, "r")
@@ -466,7 +466,7 @@ class IOBinding:
output = "Printing command: %s\n" % repr(command) + output
tkMessageBox.showerror("Print status", output, master=self.text)
else: #no printing for this platform
- message="Printing is not enabled for this platform: %s" % platform
+ message = "Printing is not enabled for this platform: %s" % platform
tkMessageBox.showinfo("Print status", message, master=self.text)
if tempfilename:
os.unlink(tempfilename)
diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt
index d45941a..d4bb009 100644
--- a/Lib/idlelib/NEWS.txt
+++ b/Lib/idlelib/NEWS.txt
@@ -1,7 +1,9 @@
What's New in IDLE 3.1.4?
=========================
-*Release date: 15-May-11*
+*Release date: XX-XXX-11*
+
+- Issue #11896: Save on Close failed despite selecting "Yes" in dialog.
- Issue #1028: Ctrl-space binding to show completions was causing IDLE to exit.
Tk < 8.5 was sending invalid Unicode null; replaced with valid null.
diff --git a/Lib/idlelib/ScriptBinding.py b/Lib/idlelib/ScriptBinding.py
index c42b29d..41e6a59 100644
--- a/Lib/idlelib/ScriptBinding.py
+++ b/Lib/idlelib/ScriptBinding.py
@@ -174,9 +174,9 @@ class ScriptBinding:
if autosave and filename:
self.editwin.io.save(None)
else:
- reply = self.ask_save_dialog()
+ confirm = self.ask_save_dialog()
self.editwin.text.focus_set()
- if reply == "ok":
+ if confirm:
self.editwin.io.save(None)
filename = self.editwin.io.filename
else:
@@ -185,13 +185,11 @@ class ScriptBinding:
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()
+ confirm = tkMessageBox.askokcancel(title="Save Before Run or Check",
+ message=msg,
+ default=tkMessageBox.OK,
+ master=self.editwin.text)
+ return confirm
def errorbox(self, title, message):
# XXX This should really be a function of EditorWindow...