|
38 | 38 | import re |
39 | 39 | import socket |
40 | 40 | import subprocess |
| 41 | +from textwrap import TextWrapper |
41 | 42 | import threading |
42 | 43 | import time |
43 | 44 | import tokenize |
@@ -1273,6 +1274,14 @@ def showprompt(self): |
1273 | 1274 | self.set_line_and_column() |
1274 | 1275 | self.io.reset_undo() |
1275 | 1276 |
|
| 1277 | + def show_warning(self, msg): |
| 1278 | + width = self.interp.tkconsole.width |
| 1279 | + wrapper = TextWrapper(width=width, tabsize=8, expand_tabs=True) |
| 1280 | + wrapped_msg = '\n'.join(wrapper.wrap(msg)) |
| 1281 | + if not wrapped_msg.endswith('\n'): |
| 1282 | + wrapped_msg += '\n' |
| 1283 | + self.per.bottom.insert("iomark linestart", wrapped_msg, "stderr") |
| 1284 | + |
1276 | 1285 | def resetoutput(self): |
1277 | 1286 | source = self.text.get("iomark", "end-1c") |
1278 | 1287 | if self.history: |
@@ -1541,12 +1550,20 @@ def main(): |
1541 | 1550 | shell.interp.execfile(script) |
1542 | 1551 | elif shell: |
1543 | 1552 | # If there is a shell window and no cmd or script in progress, |
1544 | | - # check for problematic OS X Tk versions and print a warning |
1545 | | - # message in the IDLE shell window; this is less intrusive |
1546 | | - # than always opening a separate window. |
| 1553 | + # check for problematic issues and print warning message(s) in |
| 1554 | + # the IDLE shell window; this is less intrusive than always |
| 1555 | + # opening a separate window. |
| 1556 | + |
| 1557 | + # Warn if using a problematic OS X Tk version. |
1547 | 1558 | tkversionwarning = macosx.tkVersionWarning(root) |
1548 | 1559 | if tkversionwarning: |
1549 | | - shell.interp.runcommand("print('%s')" % tkversionwarning) |
| 1560 | + shell.show_warning(tkversionwarning) |
| 1561 | + |
| 1562 | + # Warn if the "Prefer tabs when opening documents" system |
| 1563 | + # preference is set to "Always". |
| 1564 | + prefer_tabs_preference_warning = macosx.preferTabsPreferenceWarning() |
| 1565 | + if prefer_tabs_preference_warning: |
| 1566 | + shell.show_warning(prefer_tabs_preference_warning) |
1550 | 1567 |
|
1551 | 1568 | while flist.inversedict: # keep IDLE running while files are open. |
1552 | 1569 | root.mainloop() |
|
0 commit comments