update
This commit is contained in:
32
.CondaPkg/env/Lib/idlelib/iomenu.py
vendored
32
.CondaPkg/env/Lib/idlelib/iomenu.py
vendored
@@ -7,7 +7,7 @@ import tokenize
|
||||
|
||||
from tkinter import filedialog
|
||||
from tkinter import messagebox
|
||||
from tkinter.simpledialog import askstring
|
||||
from tkinter.simpledialog import askstring # loadfile encoding.
|
||||
|
||||
from idlelib.config import idleConf
|
||||
from idlelib.util import py_extensions
|
||||
@@ -180,24 +180,25 @@ class IOBinding:
|
||||
return True
|
||||
|
||||
def maybesave(self):
|
||||
"""Return 'yes', 'no', 'cancel' as appropriate.
|
||||
|
||||
Tkinter messagebox.askyesnocancel converts these tk responses
|
||||
to True, False, None. Convert back, as now expected elsewhere.
|
||||
"""
|
||||
if self.get_saved():
|
||||
return "yes"
|
||||
message = "Do you want to save %s before closing?" % (
|
||||
self.filename or "this untitled document")
|
||||
message = ("Do you want to save "
|
||||
f"{self.filename or 'this untitled document'}"
|
||||
" before closing?")
|
||||
confirm = messagebox.askyesnocancel(
|
||||
title="Save On Close",
|
||||
message=message,
|
||||
default=messagebox.YES,
|
||||
parent=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"
|
||||
reply = "yes" if self.get_saved() else "cancel"
|
||||
else: reply = "cancel" if confirm is None else "no"
|
||||
self.text.focus_set()
|
||||
return reply
|
||||
|
||||
@@ -393,13 +394,15 @@ class IOBinding:
|
||||
if self.editwin.flist:
|
||||
self.editwin.update_recent_files_list(filename)
|
||||
|
||||
|
||||
def _io_binding(parent): # htest #
|
||||
from tkinter import Toplevel, Text
|
||||
|
||||
root = Toplevel(parent)
|
||||
root.title("Test IOBinding")
|
||||
top = Toplevel(parent)
|
||||
top.title("Test IOBinding")
|
||||
x, y = map(int, parent.geometry().split('+')[1:])
|
||||
root.geometry("+%d+%d" % (x, y + 175))
|
||||
top.geometry("+%d+%d" % (x, y + 175))
|
||||
|
||||
class MyEditWin:
|
||||
def __init__(self, text):
|
||||
self.text = text
|
||||
@@ -423,12 +426,13 @@ def _io_binding(parent): # htest #
|
||||
def savecopy(self, event):
|
||||
self.text.event_generate("<<save-copy-of-window-as-file>>")
|
||||
|
||||
text = Text(root)
|
||||
text = Text(top)
|
||||
text.pack()
|
||||
text.focus_set()
|
||||
editwin = MyEditWin(text)
|
||||
IOBinding(editwin)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from unittest import main
|
||||
main('idlelib.idle_test.test_iomenu', verbosity=2, exit=False)
|
||||
|
||||
Reference in New Issue
Block a user