1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
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, 265, 365, 281)
if module:
TE.TETextBox('Importing: ' + module, rect, 0)
if not _progress:
Qd.FrameRect((35, 281, 365, 289))
pos = min(36 + 330 * _progress / 44, 364)
Qd.PaintRect((36, 282, pos, 288))
_progress = _progress + 1
else:
Qd.EraseRect(rect)
Qd.PaintRect((36, 282, pos, 288))
Qd.QDFlushPortBuffer(splash.GetDialogWindow().GetWindowPort(), None)
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
abouttext1 = """The Python Integrated Development Environment for the Macintoshˇ
Version: %s
Copyright 1997-2000 Just van Rossum, Letterror. <just@letterror.com>
Python %s
%s
See: <http://www.python.org/> for information and documentation."""
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?',
"""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!"""
]
def skipdoublereturns(text):
return string.replace(text, '\n\n', '\n')
def nl2return(text):
return string.replace(text, '\n', '\r')
def UpdateSplash(drawdialog = 0, what = 0):
if drawdialog:
splash.DrawDialog()
drawtext(what)
splash.GetDialogWindow().ValidWindowRect(splash.GetDialogPort().portRect)
Qd.QDFlushPortBuffer(splash.GetDialogWindow().GetWindowPort(), None)
def drawtext(what = 0):
Qd.SetPort(splash)
fontID = Fm.GetFNum("Python-Sans")
if not fontID:
fontID = geneva
Qd.TextFont(fontID)
Qd.TextSize(9)
rect = (10, 115, 390, 290)
if not what:
import __main__
abouttxt = nl2return(abouttext1 % (
__main__.__version__, sys.version, skipdoublereturns(sys.copyright)))
else:
import random
abouttxt = nl2return(random.choice(flauwekul))
TE.TETextBox(abouttxt, rect, teJustCenter)
UpdateSplash(1)
def wait():
import Evt
import Events
global splash
try:
splash
except NameError:
return
Qd.InitCursor()
time = Evt.TickCount()
whattext = 0
while _keepsplashscreenopen:
ok, event = Evt.EventAvail(Events.highLevelEventMask)
if ok:
# got apple event, back to mainloop
break
ok, event = Evt.EventAvail(Events.mDownMask | Events.keyDownMask | Events.updateMask)
if ok:
ok, event = Evt.WaitNextEvent(Events.mDownMask | Events.keyDownMask | Events.updateMask, 30)
if ok:
(what, message, when, where, modifiers) = event
if what == Events.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()
|