2001-08-25 09:15:04 -03:00
|
|
|
from Carbon import Dlg
|
|
|
|
from Carbon import Res
|
1999-01-30 18:39:17 -04:00
|
|
|
|
|
|
|
splash = Dlg.GetNewDialog(468, -1)
|
|
|
|
splash.DrawDialog()
|
|
|
|
|
2001-08-25 09:15:04 -03:00
|
|
|
from Carbon import Qd, TE, Fm
|
|
|
|
import sys
|
1999-01-30 18:39:17 -04:00
|
|
|
|
|
|
|
_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
|
|
|
|
|
2001-06-19 18:37:33 -03:00
|
|
|
_about_width = 440
|
|
|
|
_about_height = 340
|
|
|
|
|
1999-01-30 18:39:17 -04:00
|
|
|
def importing(module):
|
|
|
|
global _progress
|
|
|
|
Qd.SetPort(splash)
|
|
|
|
fontID = Fm.GetFNum("Python-Sans")
|
|
|
|
if not fontID:
|
2001-08-25 09:15:04 -03:00
|
|
|
from Carbon.Fonts import geneva
|
1999-01-30 18:39:17 -04:00
|
|
|
fontID = geneva
|
|
|
|
Qd.TextFont(fontID)
|
|
|
|
Qd.TextSize(9)
|
2001-06-19 18:37:33 -03:00
|
|
|
labelrect = (35, _about_height - 35, _about_width - 35, _about_height - 19)
|
|
|
|
framerect = (35, _about_height - 19, _about_width - 35, _about_height - 11)
|
|
|
|
l, t, r, b = progrect = Qd.InsetRect(framerect, 1, 1)
|
1999-01-30 18:39:17 -04:00
|
|
|
if module:
|
2001-06-19 18:37:33 -03:00
|
|
|
TE.TETextBox('Importing: ' + module, labelrect, 0)
|
1999-01-30 18:39:17 -04:00
|
|
|
if not _progress:
|
2001-06-19 18:37:33 -03:00
|
|
|
Qd.FrameRect(framerect)
|
|
|
|
pos = min(r, l + ((r - l) * _progress) / 44)
|
|
|
|
Qd.PaintRect((l, t, pos, b))
|
1999-01-30 18:39:17 -04:00
|
|
|
_progress = _progress + 1
|
|
|
|
else:
|
2001-06-19 18:37:33 -03:00
|
|
|
Qd.EraseRect(labelrect)
|
|
|
|
Qd.PaintRect((l, t, pos, b))
|
2001-03-15 10:35:33 -04:00
|
|
|
Qd.QDFlushPortBuffer(splash.GetDialogWindow().GetWindowPort(), None)
|
1999-01-30 18:39:17 -04:00
|
|
|
|
|
|
|
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)
|
|
|
|
|
2001-08-19 19:00:20 -03:00
|
|
|
#install_importhook()
|
1999-01-30 18:39:17 -04:00
|
|
|
|
|
|
|
kHighLevelEvent = 23
|
2001-08-25 09:15:04 -03:00
|
|
|
from Carbon import Win
|
|
|
|
from Carbon.Fonts import *
|
|
|
|
from Carbon.QuickDraw import *
|
|
|
|
from Carbon.TextEdit import *
|
1999-01-30 18:39:17 -04:00
|
|
|
import string
|
|
|
|
import sys
|
|
|
|
|
|
|
|
_keepsplashscreenopen = 0
|
|
|
|
|
2001-06-19 18:37:33 -03:00
|
|
|
abouttext1 = """The Python Integrated Development Environment for the Macintosh\xaa
|
1999-01-30 18:39:17 -04:00
|
|
|
Version: %s
|
2001-06-19 18:37:33 -03:00
|
|
|
Copyright 1997-2001 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."""
|
|
|
|
|
2001-06-19 18:37:33 -03:00
|
|
|
flauwekul = [ "Goodday, Bruce.",
|
|
|
|
"What's new?",
|
|
|
|
"Nudge, nudge, say no more!",
|
|
|
|
"No, no sir, it's not dead. It's resting.",
|
|
|
|
"Albatros!",
|
|
|
|
"It's . . .",
|
|
|
|
"Is your name not Bruce, then?",
|
1999-01-30 18:39:17 -04:00
|
|
|
"""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)
|
2001-01-23 10:58:20 -04:00
|
|
|
splash.GetDialogWindow().ValidWindowRect(splash.GetDialogPort().portRect)
|
2001-03-15 10:35:33 -04:00
|
|
|
Qd.QDFlushPortBuffer(splash.GetDialogWindow().GetWindowPort(), None)
|
1999-01-30 18:39:17 -04:00
|
|
|
|
|
|
|
def drawtext(what = 0):
|
|
|
|
Qd.SetPort(splash)
|
|
|
|
fontID = Fm.GetFNum("Python-Sans")
|
|
|
|
if not fontID:
|
|
|
|
fontID = geneva
|
|
|
|
Qd.TextFont(fontID)
|
|
|
|
Qd.TextSize(9)
|
2001-06-19 18:37:33 -03:00
|
|
|
rect = (10, 115, _about_width - 10, _about_height - 30)
|
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():
|
2001-08-25 09:15:04 -03:00
|
|
|
from Carbon import Evt
|
|
|
|
from Carbon import Events
|
1999-01-30 18:39:17 -04:00
|
|
|
global splash
|
|
|
|
try:
|
|
|
|
splash
|
|
|
|
except NameError:
|
|
|
|
return
|
|
|
|
Qd.InitCursor()
|
|
|
|
time = Evt.TickCount()
|
|
|
|
whattext = 0
|
2001-06-19 18:37:33 -03:00
|
|
|
drawtext(whattext)
|
1999-01-30 18:39:17 -04:00
|
|
|
while _keepsplashscreenopen:
|
2001-02-09 11:56:19 -04:00
|
|
|
ok, event = Evt.EventAvail(Events.highLevelEventMask)
|
1999-01-30 18:39:17 -04:00
|
|
|
if ok:
|
|
|
|
# got apple event, back to mainloop
|
|
|
|
break
|
2001-02-09 11:56:19 -04:00
|
|
|
ok, event = Evt.EventAvail(Events.mDownMask | Events.keyDownMask | Events.updateMask)
|
1999-01-30 18:39:17 -04:00
|
|
|
if ok:
|
2001-02-09 11:56:19 -04:00
|
|
|
ok, event = Evt.WaitNextEvent(Events.mDownMask | Events.keyDownMask | Events.updateMask, 30)
|
1999-01-30 18:39:17 -04:00
|
|
|
if ok:
|
|
|
|
(what, message, when, where, modifiers) = event
|
2001-02-09 11:56:19 -04:00
|
|
|
if what == Events.updateEvt:
|
1999-01-30 18:39:17 -04:00
|
|
|
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
|
2001-06-19 18:37:33 -03:00
|
|
|
|
1999-01-30 18:39:17 -04:00
|
|
|
|
|
|
|
def about():
|
|
|
|
global splash, splashresfile, _keepsplashscreenopen
|
|
|
|
_keepsplashscreenopen = 1
|
|
|
|
splash = Dlg.GetNewDialog(468, -1)
|
|
|
|
splash.DrawDialog()
|
|
|
|
wait()
|