]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Patch inspired by Moshe Zadka to search for the Icons directory in the
authorGuido van Rossum <guido@python.org>
Wed, 11 Aug 1999 02:01:00 +0000 (02:01 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 11 Aug 1999 02:01:00 +0000 (02:01 +0000)
same directory as __file__, rather than searching for it along sys.path.
This works better when idle is a package.

Tools/idle/TreeWidget.py

index bb348bf69ae57f7bff5f982f8aec38dcef4e7fab..bf63bdd0746b196be6ad77fb5cb61e5f6bdbae73 100644 (file)
@@ -23,11 +23,17 @@ import imp
 import ZoomHeight
 
 ICONDIR = "Icons"
-for _dir in sys.path:
-    _dir = os.path.join(_dir, ICONDIR)
-    if os.path.isdir(_dir):
-        ICONDIR = _dir
-        break
+
+# If this file is <prefix>/lib/python1.5/idle/TreeWidget.py,
+# we expect to find the icons in <prefix>/lib/python1.5/Icons/
+try:
+    _icondir = os.path.join(os.path.dirname(__file__), ICONDIR)
+except NameError:
+    _icondir = ICONDIR
+if os.path.isdir(_icondir):
+    ICONDIR = _icondir
+elif not os.path.isdir(ICONDIR):
+    raise RuntimeError, "can't find icon directory (%s)" % `ICONDIR`
 
 def listicons(icondir=ICONDIR):
     """Utility to display the available icons."""