Mercurial > cpython-lru_cache-weakref
annotate Lib/tkinter/_fix.py @ 48416:fb02fedfe647
Merged revisions 64677 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r64677 | brett.cannon | 2008-07-02 14:52:42 -0700 (Wed, 02 Jul 2008) | 2 lines
Revert r64673 and instead just change the file encoding.
........
| author | Brett Cannon <bcannon@gmail.com> |
|---|---|
| date | Wed, 02 Jul 2008 22:06:12 +0000 |
| parents | d63344ba1878 |
| children | 59d5e70f3494 |
| rev | line source |
|---|---|
|
22038
e6d44cf29dbf
backport loewis' checkin of
Michael W. Hudson <mwh@python.net>
parents:
20387
diff
changeset
|
1 import sys, os |
|
e6d44cf29dbf
backport loewis' checkin of
Michael W. Hudson <mwh@python.net>
parents:
20387
diff
changeset
|
2 |
|
e6d44cf29dbf
backport loewis' checkin of
Michael W. Hudson <mwh@python.net>
parents:
20387
diff
changeset
|
3 # Delay import _tkinter until we have set TCL_LIBRARY, |
|
e6d44cf29dbf
backport loewis' checkin of
Michael W. Hudson <mwh@python.net>
parents:
20387
diff
changeset
|
4 # so that Tcl_FindExecutable has a chance to locate its |
|
e6d44cf29dbf
backport loewis' checkin of
Michael W. Hudson <mwh@python.net>
parents:
20387
diff
changeset
|
5 # encoding directory. |
|
e6d44cf29dbf
backport loewis' checkin of
Michael W. Hudson <mwh@python.net>
parents:
20387
diff
changeset
|
6 |
|
e6d44cf29dbf
backport loewis' checkin of
Michael W. Hudson <mwh@python.net>
parents:
20387
diff
changeset
|
7 # Unfortunately, we cannot know the TCL_LIBRARY directory |
|
e6d44cf29dbf
backport loewis' checkin of
Michael W. Hudson <mwh@python.net>
parents:
20387
diff
changeset
|
8 # if we don't know the tcl version, which we cannot find out |
|
e6d44cf29dbf
backport loewis' checkin of
Michael W. Hudson <mwh@python.net>
parents:
20387
diff
changeset
|
9 # without import Tcl. Fortunately, Tcl will itself look in |
|
e6d44cf29dbf
backport loewis' checkin of
Michael W. Hudson <mwh@python.net>
parents:
20387
diff
changeset
|
10 # <TCL_LIBRARY>\..\tcl<TCL_VERSION>, so anything close to |
|
e6d44cf29dbf
backport loewis' checkin of
Michael W. Hudson <mwh@python.net>
parents:
20387
diff
changeset
|
11 # the real Tcl library will do. |
|
20387
f908b063f28b
Suggestion from SF patch #470433 to avoid clobbering TCL_LIBRARY et
Guido van Rossum <guido@python.org>
parents:
15324
diff
changeset
|
12 |
|
22038
e6d44cf29dbf
backport loewis' checkin of
Michael W. Hudson <mwh@python.net>
parents:
20387
diff
changeset
|
13 prefix = os.path.join(sys.prefix,"tcl") |
|
44349
4dc01402d78a
Merged revisions 59541-59561 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
39592
diff
changeset
|
14 if not os.path.exists(prefix): |
|
4dc01402d78a
Merged revisions 59541-59561 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
39592
diff
changeset
|
15 # devdir/../tcltk/lib |
|
4dc01402d78a
Merged revisions 59541-59561 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
39592
diff
changeset
|
16 prefix = os.path.join(sys.prefix, os.path.pardir, "tcltk", "lib") |
|
4dc01402d78a
Merged revisions 59541-59561 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
39592
diff
changeset
|
17 prefix = os.path.abspath(prefix) |
|
22038
e6d44cf29dbf
backport loewis' checkin of
Michael W. Hudson <mwh@python.net>
parents:
20387
diff
changeset
|
18 # if this does not exist, no further search is needed |
|
e6d44cf29dbf
backport loewis' checkin of
Michael W. Hudson <mwh@python.net>
parents:
20387
diff
changeset
|
19 if os.path.exists(prefix): |
|
39592
0f135affabf2
Couple more has_keys() going...
Guido van Rossum <guido@python.org>
parents:
26135
diff
changeset
|
20 if "TCL_LIBRARY" not in os.environ: |
|
22038
e6d44cf29dbf
backport loewis' checkin of
Michael W. Hudson <mwh@python.net>
parents:
20387
diff
changeset
|
21 for name in os.listdir(prefix): |
|
e6d44cf29dbf
backport loewis' checkin of
Michael W. Hudson <mwh@python.net>
parents:
20387
diff
changeset
|
22 if name.startswith("tcl"): |
|
e6d44cf29dbf
backport loewis' checkin of
Michael W. Hudson <mwh@python.net>
parents:
20387
diff
changeset
|
23 tcldir = os.path.join(prefix,name) |
|
e6d44cf29dbf
backport loewis' checkin of
Michael W. Hudson <mwh@python.net>
parents:
20387
diff
changeset
|
24 if os.path.isdir(tcldir): |
|
e6d44cf29dbf
backport loewis' checkin of
Michael W. Hudson <mwh@python.net>
parents:
20387
diff
changeset
|
25 os.environ["TCL_LIBRARY"] = tcldir |
|
26135
f4278af8eefa
Search for tix subdirectories. Fixes #564729. Will backport to 2.2.
Martin v. Löwis <martin@v.loewis.de>
parents:
22038
diff
changeset
|
26 # Compute TK_LIBRARY, knowing that it has the same version |
|
f4278af8eefa
Search for tix subdirectories. Fixes #564729. Will backport to 2.2.
Martin v. Löwis <martin@v.loewis.de>
parents:
22038
diff
changeset
|
27 # as Tcl |
|
22038
e6d44cf29dbf
backport loewis' checkin of
Michael W. Hudson <mwh@python.net>
parents:
20387
diff
changeset
|
28 import _tkinter |
|
e6d44cf29dbf
backport loewis' checkin of
Michael W. Hudson <mwh@python.net>
parents:
20387
diff
changeset
|
29 ver = str(_tkinter.TCL_VERSION) |
|
39592
0f135affabf2
Couple more has_keys() going...
Guido van Rossum <guido@python.org>
parents:
26135
diff
changeset
|
30 if "TK_LIBRARY" not in os.environ: |
|
26135
f4278af8eefa
Search for tix subdirectories. Fixes #564729. Will backport to 2.2.
Martin v. Löwis <martin@v.loewis.de>
parents:
22038
diff
changeset
|
31 v = os.path.join(prefix, 'tk'+ver) |
|
f4278af8eefa
Search for tix subdirectories. Fixes #564729. Will backport to 2.2.
Martin v. Löwis <martin@v.loewis.de>
parents:
22038
diff
changeset
|
32 if os.path.exists(os.path.join(v, "tclIndex")): |
|
f4278af8eefa
Search for tix subdirectories. Fixes #564729. Will backport to 2.2.
Martin v. Löwis <martin@v.loewis.de>
parents:
22038
diff
changeset
|
33 os.environ['TK_LIBRARY'] = v |
|
f4278af8eefa
Search for tix subdirectories. Fixes #564729. Will backport to 2.2.
Martin v. Löwis <martin@v.loewis.de>
parents:
22038
diff
changeset
|
34 # We don't know the Tix version, so we must search the entire |
|
f4278af8eefa
Search for tix subdirectories. Fixes #564729. Will backport to 2.2.
Martin v. Löwis <martin@v.loewis.de>
parents:
22038
diff
changeset
|
35 # directory |
|
39592
0f135affabf2
Couple more has_keys() going...
Guido van Rossum <guido@python.org>
parents:
26135
diff
changeset
|
36 if "TIX_LIBRARY" not in os.environ: |
|
26135
f4278af8eefa
Search for tix subdirectories. Fixes #564729. Will backport to 2.2.
Martin v. Löwis <martin@v.loewis.de>
parents:
22038
diff
changeset
|
37 for name in os.listdir(prefix): |
|
f4278af8eefa
Search for tix subdirectories. Fixes #564729. Will backport to 2.2.
Martin v. Löwis <martin@v.loewis.de>
parents:
22038
diff
changeset
|
38 if name.startswith("tix"): |
|
f4278af8eefa
Search for tix subdirectories. Fixes #564729. Will backport to 2.2.
Martin v. Löwis <martin@v.loewis.de>
parents:
22038
diff
changeset
|
39 tixdir = os.path.join(prefix,name) |
|
f4278af8eefa
Search for tix subdirectories. Fixes #564729. Will backport to 2.2.
Martin v. Löwis <martin@v.loewis.de>
parents:
22038
diff
changeset
|
40 if os.path.isdir(tixdir): |
|
f4278af8eefa
Search for tix subdirectories. Fixes #564729. Will backport to 2.2.
Martin v. Löwis <martin@v.loewis.de>
parents:
22038
diff
changeset
|
41 os.environ["TIX_LIBRARY"] = tixdir |
