summaryrefslogtreecommitdiff
path: root/Lib/idlelib/pyshell.py
diff options
context:
space:
mode:
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 47eef4399c..81a97ef6d6 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()