mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Import MacOS at the top instead of insize Tk.__init__() -- the latter
repeats the I/O for the failed import on each interpreter creation.
This commit is contained in:
parent
c9b8a57040
commit
f0c891a2b2
1 changed files with 7 additions and 10 deletions
|
@ -8,6 +8,10 @@ TclError = _tkinter.TclError
|
||||||
from types import *
|
from types import *
|
||||||
from Tkconstants import *
|
from Tkconstants import *
|
||||||
import string; _string = string; del string
|
import string; _string = string; del string
|
||||||
|
try:
|
||||||
|
import MacOS; _MacOS = MacOS; del MacOS
|
||||||
|
except ImportError:
|
||||||
|
_MacOS = None
|
||||||
|
|
||||||
TkVersion = _string.atof(_tkinter.TK_VERSION)
|
TkVersion = _string.atof(_tkinter.TK_VERSION)
|
||||||
TclVersion = _string.atof(_tkinter.TCL_VERSION)
|
TclVersion = _string.atof(_tkinter.TCL_VERSION)
|
||||||
|
@ -845,18 +849,11 @@ class Tk(Misc, Wm):
|
||||||
baseName, ext = os.path.splitext(baseName)
|
baseName, ext = os.path.splitext(baseName)
|
||||||
if ext not in ('.py', 'pyc'): baseName = baseName + ext
|
if ext not in ('.py', 'pyc'): baseName = baseName + ext
|
||||||
self.tk = _tkinter.create(screenName, baseName, className)
|
self.tk = _tkinter.create(screenName, baseName, className)
|
||||||
try:
|
if _MacOS:
|
||||||
# Disable event scanning except for Command-Period
|
# Disable event scanning except for Command-Period
|
||||||
import MacOS
|
_MacOS.SchedParams(1, 0)
|
||||||
try:
|
|
||||||
MacOS.SchedParams(1, 0)
|
|
||||||
except AttributeError:
|
|
||||||
# pre-1.5, use old routine
|
|
||||||
MacOS.EnableAppswitch(0)
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
# Work around nasty MacTk bug
|
# Work around nasty MacTk bug
|
||||||
|
# XXX Is this one still needed?
|
||||||
self.update()
|
self.update()
|
||||||
# Version sanity checks
|
# Version sanity checks
|
||||||
tk_version = self.tk.getvar('tk_version')
|
tk_version = self.tk.getvar('tk_version')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue