summaryrefslogtreecommitdiffstats
path: root/Lib/tkinter/_fix.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-05-17 18:28:57 (GMT)
committerGeorg Brandl <georg@python.org>2008-05-17 18:28:57 (GMT)
commit330231238327558337b9d8dbabe3a3b02641501d (patch)
treeec8f070c5b823e470045eaad31eae2105dff48a1 /Lib/tkinter/_fix.py
parent094c4ffe5915bf2700be833bcf42c2e64b1dab69 (diff)
downloadcpython-330231238327558337b9d8dbabe3a3b02641501d.zip
cpython-330231238327558337b9d8dbabe3a3b02641501d.tar.gz
cpython-330231238327558337b9d8dbabe3a3b02641501d.tar.bz2
Tkinter move, part 1: move modules.
Diffstat (limited to 'Lib/tkinter/_fix.py')
-rw-r--r--Lib/tkinter/_fix.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/Lib/tkinter/_fix.py b/Lib/tkinter/_fix.py
new file mode 100644
index 0000000..8820cba
--- /dev/null
+++ b/Lib/tkinter/_fix.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 "TCL_LIBRARY" not in os.environ:
+ 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 "TK_LIBRARY" not in os.environ:
+ 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 "TIX_LIBRARY" not in os.environ:
+ 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