summaryrefslogtreecommitdiff
path: root/sys/lib/python/lib-tk/FixTk.py
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@localhost>2011-05-03 11:25:13 +0000
committercinap_lenrek <cinap_lenrek@localhost>2011-05-03 11:25:13 +0000
commit458120dd40db6b4df55a4e96b650e16798ef06a0 (patch)
tree8f82685be24fef97e715c6f5ca4c68d34d5074ee /sys/lib/python/lib-tk/FixTk.py
parent3a742c699f6806c1145aea5149bf15de15a0afd7 (diff)
add hg and python
Diffstat (limited to 'sys/lib/python/lib-tk/FixTk.py')
-rw-r--r--sys/lib/python/lib-tk/FixTk.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/sys/lib/python/lib-tk/FixTk.py b/sys/lib/python/lib-tk/FixTk.py
new file mode 100644
index 000000000..a7801a250
--- /dev/null
+++ b/sys/lib/python/lib-tk/FixTk.py
@@ -0,0 +1,37 @@
+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
+ # 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