diff options
author | Guido van Rossum <guido@python.org> | 1998-04-29 21:43:36 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1998-04-29 21:43:36 (GMT) |
commit | f0c891a2b2ed16a34ab433f6e084adf9c4647d25 (patch) | |
tree | 6e81181e33a8a719c5591d4861b9d8cbb722f451 | |
parent | c9b8a570407cc4d9be43a4c0f9d1ca45bcd0d470 (diff) | |
download | cpython-f0c891a2b2ed16a34ab433f6e084adf9c4647d25.zip cpython-f0c891a2b2ed16a34ab433f6e084adf9c4647d25.tar.gz cpython-f0c891a2b2ed16a34ab433f6e084adf9c4647d25.tar.bz2 |
Import MacOS at the top instead of insize Tk.__init__() -- the latter
repeats the I/O for the failed import on each interpreter creation.
-rw-r--r-- | Lib/lib-tk/Tkinter.py | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/Lib/lib-tk/Tkinter.py b/Lib/lib-tk/Tkinter.py index bc7dae7..583e226 100644 --- a/Lib/lib-tk/Tkinter.py +++ b/Lib/lib-tk/Tkinter.py @@ -8,6 +8,10 @@ TclError = _tkinter.TclError from types import * from Tkconstants import * import string; _string = string; del string +try: + import MacOS; _MacOS = MacOS; del MacOS +except ImportError: + _MacOS = None TkVersion = _string.atof(_tkinter.TK_VERSION) TclVersion = _string.atof(_tkinter.TCL_VERSION) @@ -845,18 +849,11 @@ class Tk(Misc, Wm): baseName, ext = os.path.splitext(baseName) if ext not in ('.py', 'pyc'): baseName = baseName + ext self.tk = _tkinter.create(screenName, baseName, className) - try: + if _MacOS: # Disable event scanning except for Command-Period - import MacOS - try: - MacOS.SchedParams(1, 0) - except AttributeError: - # pre-1.5, use old routine - MacOS.EnableAppswitch(0) - except ImportError: - pass - else: + _MacOS.SchedParams(1, 0) # Work around nasty MacTk bug + # XXX Is this one still needed? self.update() # Version sanity checks tk_version = self.tk.getvar('tk_version') |