Staging
v0.5.1
https://github.com/python/cpython
Raw File
Tip revision: 2d0f5aa9a14f63854dc1d4633effa7a24b9553a7 authored by cvs2svn on 29 March 2002, 21:23:40 UTC
This commit was manufactured by cvs2svn to create tag 'r22p1'.
Tip revision: 2d0f5aa
FixTk.py
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 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
    # Now set the other variables accordingly
    import _tkinter
    ver = str(_tkinter.TCL_VERSION)
    for t in "tk", "tix":
        key = t.upper() + "_LIBRARY"
        try:
            v = os.environ[key]
        except KeyError:
            v = os.path.join(sys.prefix, "tcl", t+ver)
            if os.path.exists(os.path.join(v, "tclIndex")):
                os.environ[key] = v
back to top