Skip to content

Commit

Permalink
Import MacOS at the top instead of insize Tk.__init__() -- the latter
Browse files Browse the repository at this point in the history
repeats the I/O for the failed import on each interpreter creation.
  • Loading branch information
gvanrossum committed Apr 29, 1998
1 parent c9b8a57 commit f0c891a
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions Lib/lib-tk/Tkinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
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)
Expand Down Expand Up @@ -845,18 +849,11 @@ def __init__(self, screenName=None, baseName=None, className='Tk'):
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')
Expand Down

0 comments on commit f0c891a

Please sign in to comment.