[Python-checkins] cpython (2.7): Issue 24759: Gracefull exit Idle if ttk import fails.

terry.reedy python-checkins at python.org
Fri Jul 31 03:17:50 CEST 2015


https://hg.python.org/cpython/rev/8203fc75b3d2
changeset:   97159:8203fc75b3d2
branch:      2.7
parent:      97151:bead9330438c
user:        Terry Jan Reedy <tjreedy at udel.edu>
date:        Thu Jul 30 21:16:09 2015 -0400
summary:
  Issue 24759: Gracefull exit Idle if ttk import fails.

files:
  Lib/idlelib/PyShell.py |  10 ++++++++++
  1 files changed, 10 insertions(+), 0 deletions(-)


diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py
--- a/Lib/idlelib/PyShell.py
+++ b/Lib/idlelib/PyShell.py
@@ -23,6 +23,16 @@
           "Your Python may not be configured for Tk. **", file=sys.__stderr__)
     sys.exit(1)
 import tkMessageBox
+try:
+    import ttk
+except:
+    root = Tk()
+    root.withdraw()
+    tkMessageBox.showerror("Idle Cannot Start",
+            "Idle now requires the Tkinter ttk module from tcl/tk 8.5+.\n"
+            + "It found tk %s and no ttk." % TkVersion,
+            parent=root)
+    sys.exit(1)
 
 from idlelib.EditorWindow import EditorWindow, fixwordbreaks
 from idlelib.FileList import FileList

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list