blob: 862d82efa0bbdea4fed9a90be25c8948858f40df [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))
Jack Jansen06646a12001-03-15 14:35:33 +000046 Qd.QDFlushPortBuffer(splash.GetDialogWindow().GetWindowPort(), None)
Just van Rossum40f9b7b1999-01-30 22:39:17 +000047
48def my__import__(name, globals=None, locals=None, fromlist=None):
49 try:
50 return sys.modules[name]
51 except KeyError:
52 try:
53 importing(name)
54 except:
55 try:
56 rv = _real__import__(name)
57 finally:
58 uninstall_importhook()
59 return rv
60 return _real__import__(name)
61
62install_importhook()
63
64kHighLevelEvent = 23
65import Win
66from Fonts import *
67from QuickDraw import *
68from TextEdit import *
69import string
70import sys
71
72_keepsplashscreenopen = 0
73
Just van Rossumc9246612000-10-20 07:35:33 +000074abouttext1 = """The Python Integrated Development Environment for the Macintosh
Just van Rossum40f9b7b1999-01-30 22:39:17 +000075Version: %s
Just van Rossum71017e51999-12-23 21:49:44 +000076Copyright 1997-2000 Just van Rossum, Letterror. <just@letterror.com>
Just van Rossum40f9b7b1999-01-30 22:39:17 +000077Python %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)
Jack Jansen73023402001-01-23 14:58:20 +0000104 splash.GetDialogWindow().ValidWindowRect(splash.GetDialogPort().portRect)
Jack Jansen06646a12001-03-15 14:35:33 +0000105 Qd.QDFlushPortBuffer(splash.GetDialogWindow().GetWindowPort(), None)
Just van Rossum40f9b7b1999-01-30 22:39:17 +0000106
107def drawtext(what = 0):
108 Qd.SetPort(splash)
109 fontID = Fm.GetFNum("Python-Sans")
110 if not fontID:
111 fontID = geneva
112 Qd.TextFont(fontID)
113 Qd.TextSize(9)
Just van Rossumc9246612000-10-20 07:35:33 +0000114 rect = (10, 115, 390, 290)
Just van Rossum40f9b7b1999-01-30 22:39:17 +0000115 if not what:
116 import __main__
Just van Rossumc9246612000-10-20 07:35:33 +0000117 abouttxt = nl2return(abouttext1 % (
118 __main__.__version__, sys.version, skipdoublereturns(sys.copyright)))
Just van Rossum40f9b7b1999-01-30 22:39:17 +0000119 else:
120 import random
121 abouttxt = nl2return(random.choice(flauwekul))
122 TE.TETextBox(abouttxt, rect, teJustCenter)
123
124UpdateSplash(1)
125
126def wait():
127 import Evt
Jack Jansendef0d8d2001-02-09 15:56:19 +0000128 import Events
Just van Rossum40f9b7b1999-01-30 22:39:17 +0000129 global splash
130 try:
131 splash
132 except NameError:
133 return
134 Qd.InitCursor()
135 time = Evt.TickCount()
136 whattext = 0
137 while _keepsplashscreenopen:
Jack Jansendef0d8d2001-02-09 15:56:19 +0000138 ok, event = Evt.EventAvail(Events.highLevelEventMask)
Just van Rossum40f9b7b1999-01-30 22:39:17 +0000139 if ok:
140 # got apple event, back to mainloop
141 break
Jack Jansendef0d8d2001-02-09 15:56:19 +0000142 ok, event = Evt.EventAvail(Events.mDownMask | Events.keyDownMask | Events.updateMask)
Just van Rossum40f9b7b1999-01-30 22:39:17 +0000143 if ok:
Jack Jansendef0d8d2001-02-09 15:56:19 +0000144 ok, event = Evt.WaitNextEvent(Events.mDownMask | Events.keyDownMask | Events.updateMask, 30)
Just van Rossum40f9b7b1999-01-30 22:39:17 +0000145 if ok:
146 (what, message, when, where, modifiers) = event
Jack Jansendef0d8d2001-02-09 15:56:19 +0000147 if what == Events.updateEvt:
Just van Rossum40f9b7b1999-01-30 22:39:17 +0000148 if Win.WhichWindow(message) == splash:
149 UpdateSplash(1, whattext)
150 else:
151 break
152 if Evt.TickCount() - time > 360:
153 whattext = not whattext
154 drawtext(whattext)
155 time = Evt.TickCount()
156 del splash
157 #Res.CloseResFile(splashresfile)
158
159def about():
160 global splash, splashresfile, _keepsplashscreenopen
161 _keepsplashscreenopen = 1
162 splash = Dlg.GetNewDialog(468, -1)
163 splash.DrawDialog()
164 wait()