blob: 0ce879af930c763b9ee4c2b2cccede4a444643fb [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)
Just van Rossumff88e462000-10-20 07:49:00 +000035 rect = (35, 265, 365, 281)
Just van Rossum40f9b7b1999-01-30 22:39:17 +000036 if module:
37 TE.TETextBox('Importing: ' + module, rect, 0)
38 if not _progress:
Just van Rossumff88e462000-10-20 07:49:00 +000039 Qd.FrameRect((35, 281, 365, 289))
Just van Rossum40f9b7b1999-01-30 22:39:17 +000040 pos = min(36 + 330 * _progress / 44, 364)
Just van Rossumff88e462000-10-20 07:49:00 +000041 Qd.PaintRect((36, 282, pos, 288))
Just van Rossum40f9b7b1999-01-30 22:39:17 +000042 _progress = _progress + 1
43 else:
44 Qd.EraseRect(rect)
Just van Rossumff88e462000-10-20 07:49:00 +000045 Qd.PaintRect((36, 282, pos, 288))
Just van Rossum40f9b7b1999-01-30 22:39:17 +000046
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 +000076Python %s
77%s
Just van Rossum40f9b7b1999-01-30 22:39:17 +000078See: <http://www.python.org/> for information and documentation."""
79
80flauwekul = [ 'Goodday, Bruce.',
Just van Rossumedab9391999-02-02 22:31:05 +000081 'What¹s new?',
Just van Rossum40f9b7b1999-01-30 22:39:17 +000082 'Nudge, nudge, say no more!',
Just van Rossumedab9391999-02-02 22:31:05 +000083 'No, no sir, it¹s not dead. It¹s resting.',
Just van Rossum40f9b7b1999-01-30 22:39:17 +000084 'Albatros!',
Just van Rossumedab9391999-02-02 22:31:05 +000085 'It¹s . . .',
Just van Rossum40f9b7b1999-01-30 22:39:17 +000086 'Is your name not Bruce, then?',
87 """But Mr F.G. Superman has a secret identity . . .
88when trouble strikes at any time . . .
89at any place . . . he is ready to become . . .
90Bicycle Repair Man!"""
91 ]
92
Just van Rossumc9246612000-10-20 07:35:33 +000093def skipdoublereturns(text):
94 return string.replace(text, '\n\n', '\n')
95
Just van Rossum40f9b7b1999-01-30 22:39:17 +000096def nl2return(text):
Just van Rossumc9246612000-10-20 07:35:33 +000097 return string.replace(text, '\n', '\r')
Just van Rossum40f9b7b1999-01-30 22:39:17 +000098
99def UpdateSplash(drawdialog = 0, what = 0):
100 if drawdialog:
101 splash.DrawDialog()
102 drawtext(what)
Jack Jansen73023402001-01-23 14:58:20 +0000103 splash.GetDialogWindow().ValidWindowRect(splash.GetDialogPort().portRect)
Just van Rossum40f9b7b1999-01-30 22:39:17 +0000104
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)
Just van Rossumc9246612000-10-20 07:35:33 +0000112 rect = (10, 115, 390, 290)
Just van Rossum40f9b7b1999-01-30 22:39:17 +0000113 if not what:
114 import __main__
Just van Rossumc9246612000-10-20 07:35:33 +0000115 abouttxt = nl2return(abouttext1 % (
116 __main__.__version__, sys.version, skipdoublereturns(sys.copyright)))
Just van Rossum40f9b7b1999-01-30 22:39:17 +0000117 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
Jack Jansendef0d8d2001-02-09 15:56:19 +0000126 import Events
Just van Rossum40f9b7b1999-01-30 22:39:17 +0000127 global splash
128 try:
129 splash
130 except NameError:
131 return
132 Qd.InitCursor()
133 time = Evt.TickCount()
134 whattext = 0
135 while _keepsplashscreenopen:
Jack Jansendef0d8d2001-02-09 15:56:19 +0000136 ok, event = Evt.EventAvail(Events.highLevelEventMask)
Just van Rossum40f9b7b1999-01-30 22:39:17 +0000137 if ok:
138 # got apple event, back to mainloop
139 break
Jack Jansendef0d8d2001-02-09 15:56:19 +0000140 ok, event = Evt.EventAvail(Events.mDownMask | Events.keyDownMask | Events.updateMask)
Just van Rossum40f9b7b1999-01-30 22:39:17 +0000141 if ok:
Jack Jansendef0d8d2001-02-09 15:56:19 +0000142 ok, event = Evt.WaitNextEvent(Events.mDownMask | Events.keyDownMask | Events.updateMask, 30)
Just van Rossum40f9b7b1999-01-30 22:39:17 +0000143 if ok:
144 (what, message, when, where, modifiers) = event
Jack Jansendef0d8d2001-02-09 15:56:19 +0000145 if what == Events.updateEvt:
Just van Rossum40f9b7b1999-01-30 22:39:17 +0000146 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()