summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1999-08-11 02:01:00 (GMT)
committerGuido van Rossum <guido@python.org>1999-08-11 02:01:00 (GMT)
commit292f2c53dab77422db01541bc8fdb64fb1732e92 (patch)
treeacbea63232c13c691330d749068cfb313a98cae8 /Tools
parent2f7df12f33e27a3df79c9a9543e96df121469c3e (diff)
downloadcpython-292f2c53dab77422db01541bc8fdb64fb1732e92.zip
cpython-292f2c53dab77422db01541bc8fdb64fb1732e92.tar.gz
cpython-292f2c53dab77422db01541bc8fdb64fb1732e92.tar.bz2
Patch inspired by Moshe Zadka to search for the Icons directory in the
same directory as __file__, rather than searching for it along sys.path. This works better when idle is a package.
Diffstat (limited to 'Tools')
-rw-r--r--Tools/idle/TreeWidget.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/Tools/idle/TreeWidget.py b/Tools/idle/TreeWidget.py
index bb348bf..bf63bdd 100644
--- a/Tools/idle/TreeWidget.py
+++ b/Tools/idle/TreeWidget.py
@@ -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."""