diff options
| author | Georg Brandl <georg@python.org> | 2008-05-20 06:58:21 (GMT) |
|---|---|---|
| committer | Georg Brandl <georg@python.org> | 2008-05-20 06:58:21 (GMT) |
| commit | 33cece05b918dff706a4298e33f84d8e8a0391d2 (patch) | |
| tree | c78da9213928978586e3e5259195a6be2d580648 /Lib/lib-tk/FixTk.py | |
| parent | 248e3a8b7f7868e72a056609605bc1e7d84b1393 (diff) | |
| download | cpython-33cece05b918dff706a4298e33f84d8e8a0391d2.zip cpython-33cece05b918dff706a4298e33f84d8e8a0391d2.tar.gz cpython-33cece05b918dff706a4298e33f84d8e8a0391d2.tar.bz2 | |
Tkinter renaming reversal: move modules back in their place.
Diffstat (limited to 'Lib/lib-tk/FixTk.py')
| -rw-r--r-- | Lib/lib-tk/FixTk.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Lib/lib-tk/FixTk.py b/Lib/lib-tk/FixTk.py new file mode 100644 index 0000000..346d3c3 --- /dev/null +++ b/Lib/lib-tk/FixTk.py @@ -0,0 +1,41 @@ +import sys, os + +# Delay import _tkinter until we have set TCL_LIBRARY, +# so that Tcl_FindExecutable has a chance to locate its +# encoding directory. + +# Unfortunately, we cannot know the TCL_LIBRARY directory +# if we don't know the tcl version, which we cannot find out +# without import Tcl. Fortunately, Tcl will itself look in +# <TCL_LIBRARY>\..\tcl<TCL_VERSION>, so anything close to +# the real Tcl library will do. + +prefix = os.path.join(sys.prefix,"tcl") +if not os.path.exists(prefix): + # devdir/../tcltk/lib + prefix = os.path.join(sys.prefix, os.path.pardir, "tcltk", "lib") + prefix = os.path.abspath(prefix) +# if this does not exist, no further search is needed +if os.path.exists(prefix): + if not os.environ.has_key("TCL_LIBRARY"): + for name in os.listdir(prefix): + if name.startswith("tcl"): + tcldir = os.path.join(prefix,name) + if os.path.isdir(tcldir): + os.environ["TCL_LIBRARY"] = tcldir + # Compute TK_LIBRARY, knowing that it has the same version + # as Tcl + import _tkinter + ver = str(_tkinter.TCL_VERSION) + if not os.environ.has_key("TK_LIBRARY"): + v = os.path.join(prefix, 'tk'+ver) + if os.path.exists(os.path.join(v, "tclIndex")): + os.environ['TK_LIBRARY'] = v + # We don't know the Tix version, so we must search the entire + # directory + if not os.environ.has_key("TIX_LIBRARY"): + for name in os.listdir(prefix): + if name.startswith("tix"): + tixdir = os.path.join(prefix,name) + if os.path.isdir(tixdir): + os.environ["TIX_LIBRARY"] = tixdir |
