mirror of
https://github.com/python/cpython.git
synced 2025-10-06 15:11:58 +00:00
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.
This commit is contained in:
parent
16501b7082
commit
9ebe8794f0
5 changed files with 69 additions and 9 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue