-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a "starter GUI" + work-a-round for tkinter usage with virtualenv …
…under windows Squashed commit of the following: commit e7beb32 Author: JensDiemer <git@jensdiemer.de> Date: Wed Aug 19 11:42:41 2015 +0200 remove obsolete starter files commit 5ed7406 Author: JensDiemer <git@jensdiemer.de> Date: Wed Aug 19 11:38:15 2015 +0200 "starter GUI" commit 0c1add8 Author: JensDiemer <git@jensdiemer.de> Date: Wed Aug 19 11:27:20 2015 +0200 Add work-a-round for tkinter usage with virtualenv under windows, see: pypa/virtualenv#93 commit a35a94c Author: JensDiemer <git@jensdiemer.de> Date: Wed Aug 19 09:42:45 2015 +0200 move settings in a frame, add status bar + code cleanup commit e6fa73e Author: JensDiemer <git@jensdiemer.de> Date: Tue Aug 18 23:06:12 2015 +0200 WIP: seperate in frame/class commit b7008d6 Author: JensDiemer <git@jensdiemer.de> Date: Tue Aug 18 22:06:48 2015 +0200 replace .sh scripts commit 3cecd83 Author: JensDiemer <git@jensdiemer.de> Date: Tue Aug 18 17:27:39 2015 +0200 WIP: starter GUI
- Loading branch information
Showing
16 changed files
with
331 additions
and
268 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,74 @@ | ||
import os | ||
import sys | ||
|
||
__version__ = "0.5.0" | ||
|
||
__version__ = "0.5.1.dev0" | ||
|
||
|
||
def fix_virtualenv_tkinter(): | ||
""" | ||
work-a-round for tkinter under windows in a virtualenv: | ||
"TclError: Can't find a usable init.tcl..." | ||
Known bug, see: https://github.com/pypa/virtualenv/issues/93 | ||
There are "fix tk" file here: | ||
C:\Python27\Lib\lib-tk\FixTk.py | ||
C:\Python34\Lib\tkinter\_fix.py | ||
These modules will be automatic imported by tkinter import. | ||
The fix set theses environment variables: | ||
TCL_LIBRARY C:\Python27\tcl\tcl8.5 | ||
TIX_LIBRARY C:\Python27\tcl\tix8.4.3 | ||
TK_LIBRARY C:\Python27\tcl\tk8.5 | ||
TCL_LIBRARY C:\Python34\tcl\tcl8.6 | ||
TIX_LIBRARY C:\Python34\tcl\tix8.4.3 | ||
TK_LIBRARY C:\Python34\tcl\tk8.6 | ||
but only if: | ||
os.path.exists(os.path.join(sys.prefix,"tcl")) | ||
And the virtualenv activate script will change the sys.prefix | ||
to the current env. So we temporary change it back to sys.real_prefix | ||
and import the fix module. | ||
If the fix module was imported before, then we reload it. | ||
""" | ||
if "TCL_LIBRARY" in os.environ: | ||
# Fix not needed (e.g. virtualenv issues #93 fixed?) | ||
return | ||
|
||
if not hasattr(sys, "real_prefix"): | ||
# we are not in a activated virtualenv | ||
return | ||
|
||
if sys.version_info[0] == 2: | ||
# Python v2 | ||
virtualprefix = sys.prefix | ||
sys.prefix = sys.real_prefix | ||
|
||
import FixTk | ||
|
||
if "TCL_LIBRARY" not in os.environ: | ||
reload(FixTk) | ||
|
||
sys.prefix = virtualprefix | ||
else: | ||
# Python v3 | ||
virtualprefix = sys.base_prefix | ||
sys.base_prefix = sys.real_prefix | ||
|
||
from tkinter import _fix | ||
|
||
if "TCL_LIBRARY" not in os.environ: | ||
from imp import reload | ||
reload(_fix) | ||
|
||
sys.base_prefix = virtualprefix | ||
|
||
|
||
if sys.platform.startswith("win"): | ||
fix_virtualenv_tkinter() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.