summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/pyshell.py
diff options
context:
space:
mode:
authorTal Einat <taleinat+github@gmail.com>2018-12-07 06:32:21 (GMT)
committerTerry Jan Reedy <tjreedy@udel.edu>2018-12-07 06:32:21 (GMT)
commit9ebe8794f003dadfff578a066ea503a3e37ffe1d (patch)
tree427935bc44f75fac3de05d16ba7d60370b2bb250 /Lib/idlelib/pyshell.py
parent16501b70826695991b3a151dfc538f010be5c765 (diff)
downloadcpython-9ebe8794f003dadfff578a066ea503a3e37ffe1d.zip
cpython-9ebe8794f003dadfff578a066ea503a3e37ffe1d.tar.gz
cpython-9ebe8794f003dadfff578a066ea503a3e37ffe1d.tar.bz2
bpo-34864: warn if "Prefer tabs when opening documents" set to "Always" (#10464)
* bpo-34864: warn if "Prefer tabs when opening documents" set to "Always" * add NEWS entry * address code review comments * address second code review comments * Add entry for idlelib/NEWS.txt.
Diffstat (limited to 'Lib/idlelib/pyshell.py')
-rwxr-xr-xLib/idlelib/pyshell.py25
1 files changed, 21 insertions, 4 deletions
diff --git a/Lib/idlelib/pyshell.py b/Lib/idlelib/pyshell.py
index 47eef43..81a97ef 100755
--- a/Lib/idlelib/pyshell.py
+++ b/Lib/idlelib/pyshell.py
@@ -38,6 +38,7 @@ from platform import python_version
import re
import socket
import subprocess
+from textwrap import TextWrapper
import threading
import time
import tokenize
@@ -1273,6 +1274,14 @@ class PyShell(OutputWindow):
self.set_line_and_column()
self.io.reset_undo()
+ def show_warning(self, msg):
+ width = self.interp.tkconsole.width
+ wrapper = TextWrapper(width=width, tabsize=8, expand_tabs=True)
+ wrapped_msg = '\n'.join(wrapper.wrap(msg))
+ if not wrapped_msg.endswith('\n'):
+ wrapped_msg += '\n'
+ self.per.bottom.insert("iomark linestart", wrapped_msg, "stderr")
+
def resetoutput(self):
source = self.text.get("iomark", "end-1c")
if self.history:
@@ -1541,12 +1550,20 @@ def main():
shell.interp.execfile(script)
elif shell:
# If there is a shell window and no cmd or script in progress,
- # check for problematic OS X Tk versions and print a warning
- # message in the IDLE shell window; this is less intrusive
- # than always opening a separate window.
+ # check for problematic issues and print warning message(s) in
+ # the IDLE shell window; this is less intrusive than always
+ # opening a separate window.
+
+ # Warn if using a problematic OS X Tk version.
tkversionwarning = macosx.tkVersionWarning(root)
if tkversionwarning:
- shell.interp.runcommand("print('%s')" % tkversionwarning)
+ shell.show_warning(tkversionwarning)
+
+ # Warn if the "Prefer tabs when opening documents" system
+ # preference is set to "Always".
+ prefer_tabs_preference_warning = macosx.preferTabsPreferenceWarning()
+ if prefer_tabs_preference_warning:
+ shell.show_warning(prefer_tabs_preference_warning)
while flist.inversedict: # keep IDLE running while files are open.
root.mainloop()