blob: 19f16fca75e28a7a6c321ca08f47ffb0eb6f96bd [file] [log] [blame]
Just van Rossum40f9b7b1999-01-30 22:39:17 +00001import Dlg
2import Res
3
4splash = Dlg.GetNewDialog(468, -1)
5splash.DrawDialog()
6
7import Qd, TE, Fm, sys
8
9_real__import__ = None
10
11def install_importhook():
12 global _real__import__
13 import __builtin__
14 if _real__import__ is None:
15 _real__import__ = __builtin__.__import__
16 __builtin__.__import__ = my__import__
17
18def uninstall_importhook():
19 global _real__import__
20 if _real__import__ is not None:
21 import __builtin__
22 __builtin__.__import__ = _real__import__
23 _real__import__ = None
24
25_progress = 0
26
27def importing(module):
28 global _progress
29 Qd.SetPort(splash)
30 fontID = Fm.GetFNum("Python-Sans")
31 if not fontID:
32 fontID = geneva
33 Qd.TextFont(fontID)
34 Qd.TextSize(9)
35 rect = (35, 260, 365, 276)
36 if module:
37 TE.TETextBox('Importing: ' + module, rect, 0)
38 if not _progress:
39 Qd.FrameRect((35, 276, 365, 284))
40 pos = min(36 + 330 * _progress / 44, 364)
41 Qd.PaintRect((36, 277, pos, 283))
42 _progress = _progress + 1
43 else:
44 Qd.EraseRect(rect)
45 Qd.PaintRect((36, 277, pos, 283))
46
47def my__import__(name, globals=None, locals=None, fromlist=None):
48 try:
49 return sys.modules[name]
50 except KeyError:
51 try:
52 importing(name)
53 except:
54 try:
55 rv = _real__import__(name)
56 finally:
57 uninstall_importhook()
58 return rv
59 return _real__import__(name)
60
61install_importhook()
62
63kHighLevelEvent = 23
64import Win
65from Fonts import *
66from QuickDraw import *
67from TextEdit import *
68import string
69import sys
70
71_keepsplashscreenopen = 0
72
73abouttext1 = """The Python Integrated Developement Environment for the Macintoshª
74Version: %s
75Copyright 1997-98 Just van Rossum, Letterror. <just@letterror.com>
76
77Python %s
78%s
79Written by Guido van Rossum with Jack Jansen (and others)
80
81See: <http://www.python.org/> for information and documentation."""
82
83flauwekul = [ 'Goodday, Bruce.',
84 'WhatÕs new?',
85 'Nudge, nudge, say no more!',
86 'No, no sir, itÕs not dead. ItÕs resting.',
87 'Albatros!',
88 'ItÕs . . .',
89 'Is your name not Bruce, then?',
90 """But Mr F.G. Superman has a secret identity . . .
91when trouble strikes at any time . . .
92at any place . . . he is ready to become . . .
93Bicycle Repair Man!"""
94 ]
95
96def nl2return(text):
97 return string.join(string.split(text, '\n'), '\r')
98
99def UpdateSplash(drawdialog = 0, what = 0):
100 if drawdialog:
101 splash.DrawDialog()
102 drawtext(what)
103 Win.ValidRect(splash.GetWindowPort().portRect)
104
105def drawtext(what = 0):
106 Qd.SetPort(splash)
107 fontID = Fm.GetFNum("Python-Sans")
108 if not fontID:
109 fontID = geneva
110 Qd.TextFont(fontID)
111 Qd.TextSize(9)
112 rect = (10, 125, 390, 260)
113 if not what:
114 import __main__
115 abouttxt = nl2return(abouttext1 \
116 % (__main__.__version__, sys.version, sys.copyright))
117 else:
118 import random
119 abouttxt = nl2return(random.choice(flauwekul))
120 TE.TETextBox(abouttxt, rect, teJustCenter)
121
122UpdateSplash(1)
123
124def wait():
125 import Evt
126 from Events import *
127 global splash
128 try:
129 splash
130 except NameError:
131 return
132 Qd.InitCursor()
133 time = Evt.TickCount()
134 whattext = 0
135 while _keepsplashscreenopen:
136 ok, event = Evt.EventAvail(highLevelEventMask)
137 if ok:
138 # got apple event, back to mainloop
139 break
140 ok, event = Evt.EventAvail(mDownMask | keyDownMask | updateMask)
141 if ok:
142 ok, event = Evt.WaitNextEvent(mDownMask | keyDownMask | updateMask, 30)
143 if ok:
144 (what, message, when, where, modifiers) = event
145 if what == updateEvt:
146 if Win.WhichWindow(message) == splash:
147 UpdateSplash(1, whattext)
148 else:
149 break
150 if Evt.TickCount() - time > 360:
151 whattext = not whattext
152 drawtext(whattext)
153 time = Evt.TickCount()
154 del splash
155 #Res.CloseResFile(splashresfile)
156
157def about():
158 global splash, splashresfile, _keepsplashscreenopen
159 _keepsplashscreenopen = 1
160 splash = Dlg.GetNewDialog(468, -1)
161 splash.DrawDialog()
162 wait()