blob: 6318810cb92c1618a963cdfae026be09e1230286 [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
Just van Rossumc9246612000-10-20 07:35:33 +000073abouttext1 = """The Python Integrated Development Environment for the Macintosh
Just van Rossum40f9b7b1999-01-30 22:39:17 +000074Version: %s
Just van Rossum71017e51999-12-23 21:49:44 +000075Copyright 1997-2000 Just van Rossum, Letterror. <just@letterror.com>
Just van Rossum40f9b7b1999-01-30 22:39:17 +000076
77Python %s
78%s
Just van Rossum40f9b7b1999-01-30 22:39:17 +000079See: <http://www.python.org/> for information and documentation."""
80
81flauwekul = [ 'Goodday, Bruce.',
Just van Rossumedab9391999-02-02 22:31:05 +000082 'What¹s new?',
Just van Rossum40f9b7b1999-01-30 22:39:17 +000083 'Nudge, nudge, say no more!',
Just van Rossumedab9391999-02-02 22:31:05 +000084 'No, no sir, it¹s not dead. It¹s resting.',
Just van Rossum40f9b7b1999-01-30 22:39:17 +000085 'Albatros!',
Just van Rossumedab9391999-02-02 22:31:05 +000086 'It¹s . . .',
Just van Rossum40f9b7b1999-01-30 22:39:17 +000087 'Is your name not Bruce, then?',
88 """But Mr F.G. Superman has a secret identity . . .
89when trouble strikes at any time . . .
90at any place . . . he is ready to become . . .
91Bicycle Repair Man!"""
92 ]
93
Just van Rossumc9246612000-10-20 07:35:33 +000094def skipdoublereturns(text):
95 return string.replace(text, '\n\n', '\n')
96
Just van Rossum40f9b7b1999-01-30 22:39:17 +000097def nl2return(text):
Just van Rossumc9246612000-10-20 07:35:33 +000098 return string.replace(text, '\n', '\r')
Just van Rossum40f9b7b1999-01-30 22:39:17 +000099
100def UpdateSplash(drawdialog = 0, what = 0):
101 if drawdialog:
102 splash.DrawDialog()
103 drawtext(what)
104 Win.ValidRect(splash.GetWindowPort().portRect)
105
106def drawtext(what = 0):
107 Qd.SetPort(splash)
108 fontID = Fm.GetFNum("Python-Sans")
109 if not fontID:
110 fontID = geneva
111 Qd.TextFont(fontID)
112 Qd.TextSize(9)
Just van Rossumc9246612000-10-20 07:35:33 +0000113 rect = (10, 115, 390, 290)
Just van Rossum40f9b7b1999-01-30 22:39:17 +0000114 if not what:
115 import __main__
Just van Rossumc9246612000-10-20 07:35:33 +0000116 abouttxt = nl2return(abouttext1 % (
117 __main__.__version__, sys.version, skipdoublereturns(sys.copyright)))
Just van Rossum40f9b7b1999-01-30 22:39:17 +0000118 else:
119 import random
120 abouttxt = nl2return(random.choice(flauwekul))
121 TE.TETextBox(abouttxt, rect, teJustCenter)
122
123UpdateSplash(1)
124
125def wait():
126 import Evt
127 from Events import *
128 global splash
129 try:
130 splash
131 except NameError:
132 return
133 Qd.InitCursor()
134 time = Evt.TickCount()
135 whattext = 0
136 while _keepsplashscreenopen:
Just van Rossumc9246612000-10-20 07:35:33 +0000137) ok, event = Evt.EventAvail(highLevelEventMask)
Just van Rossum40f9b7b1999-01-30 22:39:17 +0000138 if ok:
139 # got apple event, back to mainloop
140 break
141 ok, event = Evt.EventAvail(mDownMask | keyDownMask | updateMask)
142 if ok:
143 ok, event = Evt.WaitNextEvent(mDownMask | keyDownMask | updateMask, 30)
144 if ok:
145 (what, message, when, where, modifiers) = event
146 if what == updateEvt:
147 if Win.WhichWindow(message) == splash:
148 UpdateSplash(1, whattext)
149 else:
150 break
151 if Evt.TickCount() - time > 360:
152 whattext = not whattext
153 drawtext(whattext)
154 time = Evt.TickCount()
155 del splash
156 #Res.CloseResFile(splashresfile)
157
158def about():
159 global splash, splashresfile, _keepsplashscreenopen
160 _keepsplashscreenopen = 1
161 splash = Dlg.GetNewDialog(468, -1)
162 splash.DrawDialog()
163 wait()