Bump to 2.3.1 to pick up the missing file.
[python/dscho.git] / Mac / Tools / IDE / Splash.py
blob302053f072f28dba382dfa5ca420687dd0a7009c
1 from Carbon import Dlg
2 from Carbon import Res
4 splash = Dlg.GetNewDialog(468, -1)
5 splash.DrawDialog()
7 from Carbon import Qd, TE, Fm
9 from Carbon import Win
10 from Carbon.Fonts import *
11 from Carbon.QuickDraw import *
12 from Carbon.TextEdit import teJustCenter
13 import string
14 import sys
16 _about_width = 440
17 _about_height = 340
19 _keepsplashscreenopen = 0
21 abouttext1 = """The Python Integrated Development Environment for the Macintosh\xaa
22 Version: %s
23 Copyright 1997-2001 Just van Rossum, Letterror. <just@letterror.com>
24 Python %s
26 See: <http://www.python.org/> for information and documentation."""
28 flauwekul = [ "Goodday, Bruce.",
29 "What's new?",
30 "Nudge, nudge, say no more!",
31 "No, no sir, it's not dead. It's resting.",
32 "Albatros!",
33 "It's . . .",
34 "Is your name not Bruce, then?",
35 """But Mr F.G. Superman has a secret identity . . .
36 when trouble strikes at any time . . .
37 at any place . . . he is ready to become . . .
38 Bicycle Repair Man!"""
41 def skipdoublereturns(text):
42 return string.replace(text, '\n\n', '\n')
44 def nl2return(text):
45 return string.replace(text, '\n', '\r')
47 def UpdateSplash(drawdialog = 0, what = 0):
48 if drawdialog:
49 splash.DrawDialog()
50 drawtext(what)
51 splash.GetDialogWindow().ValidWindowRect(splash.GetDialogPort().portRect)
52 Qd.QDFlushPortBuffer(splash.GetDialogWindow().GetWindowPort(), None)
54 def drawtext(what = 0):
55 Qd.SetPort(splash)
56 fontID = Fm.GetFNum("Python-Sans")
57 if not fontID:
58 fontID = geneva
59 Qd.TextFont(fontID)
60 Qd.TextSize(9)
61 rect = (10, 115, _about_width - 10, _about_height - 30)
62 if not what:
63 import __main__
64 abouttxt = nl2return(abouttext1 % (
65 __main__.__version__, sys.version, skipdoublereturns(sys.copyright)))
66 else:
67 import random
68 abouttxt = nl2return(random.choice(flauwekul))
69 TE.TETextBox(abouttxt, rect, teJustCenter)
71 UpdateSplash(1)
73 def wait():
74 from Carbon import Evt
75 from Carbon import Events
76 global splash
77 try:
78 splash
79 except NameError:
80 return
81 Qd.InitCursor()
82 time = Evt.TickCount()
83 whattext = 0
84 drawtext(whattext)
85 while _keepsplashscreenopen:
86 ok, event = Evt.EventAvail(Events.highLevelEventMask)
87 if ok:
88 # got apple event, back to mainloop
89 break
90 ok, event = Evt.EventAvail(Events.mDownMask | Events.keyDownMask | Events.updateMask)
91 if ok:
92 ok, event = Evt.WaitNextEvent(Events.mDownMask | Events.keyDownMask | Events.updateMask, 30)
93 if ok:
94 (what, message, when, where, modifiers) = event
95 if what == Events.updateEvt:
96 if Win.WhichWindow(message) == splash:
97 UpdateSplash(1, whattext)
98 else:
99 break
100 if Evt.TickCount() - time > 360:
101 whattext = not whattext
102 drawtext(whattext)
103 time = Evt.TickCount()
104 del splash
107 def about():
108 global splash, splashresfile, _keepsplashscreenopen
109 _keepsplashscreenopen = 1
110 splash = Dlg.GetNewDialog(468, -1)
111 splash.DrawDialog()
112 wait()