1999-01-30 18:39:17 -04:00
|
|
|
|
import Dlg
|
|
|
|
|
import Res
|
|
|
|
|
|
|
|
|
|
splash = Dlg.GetNewDialog(468, -1)
|
|
|
|
|
splash.DrawDialog()
|
|
|
|
|
|
|
|
|
|
import Qd, TE, Fm, sys
|
|
|
|
|
|
|
|
|
|
_real__import__ = None
|
|
|
|
|
|
|
|
|
|
def install_importhook():
|
|
|
|
|
global _real__import__
|
|
|
|
|
import __builtin__
|
|
|
|
|
if _real__import__ is None:
|
|
|
|
|
_real__import__ = __builtin__.__import__
|
|
|
|
|
__builtin__.__import__ = my__import__
|
|
|
|
|
|
|
|
|
|
def uninstall_importhook():
|
|
|
|
|
global _real__import__
|
|
|
|
|
if _real__import__ is not None:
|
|
|
|
|
import __builtin__
|
|
|
|
|
__builtin__.__import__ = _real__import__
|
|
|
|
|
_real__import__ = None
|
|
|
|
|
|
|
|
|
|
_progress = 0
|
|
|
|
|
|
|
|
|
|
def importing(module):
|
|
|
|
|
global _progress
|
|
|
|
|
Qd.SetPort(splash)
|
|
|
|
|
fontID = Fm.GetFNum("Python-Sans")
|
|
|
|
|
if not fontID:
|
|
|
|
|
fontID = geneva
|
|
|
|
|
Qd.TextFont(fontID)
|
|
|
|
|
Qd.TextSize(9)
|
|
|
|
|
rect = (35, 260, 365, 276)
|
|
|
|
|
if module:
|
|
|
|
|
TE.TETextBox('Importing: ' + module, rect, 0)
|
|
|
|
|
if not _progress:
|
|
|
|
|
Qd.FrameRect((35, 276, 365, 284))
|
|
|
|
|
pos = min(36 + 330 * _progress / 44, 364)
|
|
|
|
|
Qd.PaintRect((36, 277, pos, 283))
|
|
|
|
|
_progress = _progress + 1
|
|
|
|
|
else:
|
|
|
|
|
Qd.EraseRect(rect)
|
|
|
|
|
Qd.PaintRect((36, 277, pos, 283))
|
|
|
|
|
|
|
|
|
|
def my__import__(name, globals=None, locals=None, fromlist=None):
|
|
|
|
|
try:
|
|
|
|
|
return sys.modules[name]
|
|
|
|
|
except KeyError:
|
|
|
|
|
try:
|
|
|
|
|
importing(name)
|
|
|
|
|
except:
|
|
|
|
|
try:
|
|
|
|
|
rv = _real__import__(name)
|
|
|
|
|
finally:
|
|
|
|
|
uninstall_importhook()
|
|
|
|
|
return rv
|
|
|
|
|
return _real__import__(name)
|
|
|
|
|
|
|
|
|
|
install_importhook()
|
|
|
|
|
|
|
|
|
|
kHighLevelEvent = 23
|
|
|
|
|
import Win
|
|
|
|
|
from Fonts import *
|
|
|
|
|
from QuickDraw import *
|
|
|
|
|
from TextEdit import *
|
|
|
|
|
import string
|
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
_keepsplashscreenopen = 0
|
|
|
|
|
|
2000-10-20 04:35:33 -03:00
|
|
|
|
abouttext1 = """The Python Integrated Development Environment for the Macintosh<73>
|
1999-01-30 18:39:17 -04:00
|
|
|
|
Version: %s
|
1999-12-23 17:49:44 -04:00
|
|
|
|
Copyright 1997-2000 Just van Rossum, Letterror. <just@letterror.com>
|
1999-01-30 18:39:17 -04:00
|
|
|
|
|
|
|
|
|
Python %s
|
|
|
|
|
%s
|
|
|
|
|
See: <http://www.python.org/> for information and documentation."""
|
|
|
|
|
|
|
|
|
|
flauwekul = [ 'Goodday, Bruce.',
|
1999-02-02 18:31:05 -04:00
|
|
|
|
'What<EFBFBD>s new?',
|
1999-01-30 18:39:17 -04:00
|
|
|
|
'Nudge, nudge, say no more!',
|
1999-02-02 18:31:05 -04:00
|
|
|
|
'No, no sir, it<69>s not dead. It<49>s resting.',
|
1999-01-30 18:39:17 -04:00
|
|
|
|
'Albatros!',
|
1999-02-02 18:31:05 -04:00
|
|
|
|
'It<EFBFBD>s . . .',
|
1999-01-30 18:39:17 -04:00
|
|
|
|
'Is your name not Bruce, then?',
|
|
|
|
|
"""But Mr F.G. Superman has a secret identity . . .
|
|
|
|
|
when trouble strikes at any time . . .
|
|
|
|
|
at any place . . . he is ready to become . . .
|
|
|
|
|
Bicycle Repair Man!"""
|
|
|
|
|
]
|
|
|
|
|
|
2000-10-20 04:35:33 -03:00
|
|
|
|
def skipdoublereturns(text):
|
|
|
|
|
return string.replace(text, '\n\n', '\n')
|
|
|
|
|
|
1999-01-30 18:39:17 -04:00
|
|
|
|
def nl2return(text):
|
2000-10-20 04:35:33 -03:00
|
|
|
|
return string.replace(text, '\n', '\r')
|
1999-01-30 18:39:17 -04:00
|
|
|
|
|
|
|
|
|
def UpdateSplash(drawdialog = 0, what = 0):
|
|
|
|
|
if drawdialog:
|
|
|
|
|
splash.DrawDialog()
|
|
|
|
|
drawtext(what)
|
|
|
|
|
Win.ValidRect(splash.GetWindowPort().portRect)
|
|
|
|
|
|
|
|
|
|
def drawtext(what = 0):
|
|
|
|
|
Qd.SetPort(splash)
|
|
|
|
|
fontID = Fm.GetFNum("Python-Sans")
|
|
|
|
|
if not fontID:
|
|
|
|
|
fontID = geneva
|
|
|
|
|
Qd.TextFont(fontID)
|
|
|
|
|
Qd.TextSize(9)
|
2000-10-20 04:35:33 -03:00
|
|
|
|
rect = (10, 115, 390, 290)
|
1999-01-30 18:39:17 -04:00
|
|
|
|
if not what:
|
|
|
|
|
import __main__
|
2000-10-20 04:35:33 -03:00
|
|
|
|
abouttxt = nl2return(abouttext1 % (
|
|
|
|
|
__main__.__version__, sys.version, skipdoublereturns(sys.copyright)))
|
1999-01-30 18:39:17 -04:00
|
|
|
|
else:
|
|
|
|
|
import random
|
|
|
|
|
abouttxt = nl2return(random.choice(flauwekul))
|
|
|
|
|
TE.TETextBox(abouttxt, rect, teJustCenter)
|
|
|
|
|
|
|
|
|
|
UpdateSplash(1)
|
|
|
|
|
|
|
|
|
|
def wait():
|
|
|
|
|
import Evt
|
|
|
|
|
from Events import *
|
|
|
|
|
global splash
|
|
|
|
|
try:
|
|
|
|
|
splash
|
|
|
|
|
except NameError:
|
|
|
|
|
return
|
|
|
|
|
Qd.InitCursor()
|
|
|
|
|
time = Evt.TickCount()
|
|
|
|
|
whattext = 0
|
|
|
|
|
while _keepsplashscreenopen:
|
2000-10-20 04:35:33 -03:00
|
|
|
|
) ok, event = Evt.EventAvail(highLevelEventMask)
|
1999-01-30 18:39:17 -04:00
|
|
|
|
if ok:
|
|
|
|
|
# got apple event, back to mainloop
|
|
|
|
|
break
|
|
|
|
|
ok, event = Evt.EventAvail(mDownMask | keyDownMask | updateMask)
|
|
|
|
|
if ok:
|
|
|
|
|
ok, event = Evt.WaitNextEvent(mDownMask | keyDownMask | updateMask, 30)
|
|
|
|
|
if ok:
|
|
|
|
|
(what, message, when, where, modifiers) = event
|
|
|
|
|
if what == updateEvt:
|
|
|
|
|
if Win.WhichWindow(message) == splash:
|
|
|
|
|
UpdateSplash(1, whattext)
|
|
|
|
|
else:
|
|
|
|
|
break
|
|
|
|
|
if Evt.TickCount() - time > 360:
|
|
|
|
|
whattext = not whattext
|
|
|
|
|
drawtext(whattext)
|
|
|
|
|
time = Evt.TickCount()
|
|
|
|
|
del splash
|
|
|
|
|
#Res.CloseResFile(splashresfile)
|
|
|
|
|
|
|
|
|
|
def about():
|
|
|
|
|
global splash, splashresfile, _keepsplashscreenopen
|
|
|
|
|
_keepsplashscreenopen = 1
|
|
|
|
|
splash = Dlg.GetNewDialog(468, -1)
|
|
|
|
|
splash.DrawDialog()
|
|
|
|
|
wait()
|