]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/wx/lib/splashscreen.py
1 #----------------------------------------------------------------------
2 # Name: wxPython.lib.splashscreen
3 # Purpose: A simple frame that can display a bitmap and closes itself
4 # after a specified timeout or a mouse click.
6 # Author: Mike Fletcher, Robin Dunn
10 # Copyright: (c) 1999 by Total Control Software
11 # Licence: wxWindows license
12 #----------------------------------------------------------------------
13 # 12/11/2003 - Jeff Grimmett (grimmtooth@softhome.net)
15 # o 2.5 compatability update.
20 A Splash Screen implemented in Python.
22 NOTE: Now that wxWindows has a wxSplashScrren class and it is wrapped
23 in wxPython this class is deprecated. See the docs for more details.
31 #####################################################\
32 # THIS MODULE IS NOW DEPRECATED |
34 # The core wx library now contains an implementation |
35 # of the 'real' wx.SpashScreen. |
36 #####################################################/
40 warnings
.warn(warningmsg
, DeprecationWarning, stacklevel
=2)
43 #----------------------------------------------------------------------
45 class SplashScreen(wx
.Frame
):
46 def __init__(self
, parent
, ID
=-1, title
="SplashScreen",
47 style
=wx
.SIMPLE_BORDER|wx
.STAY_ON_TOP
,
48 duration
=1500, bitmapfile
="bitmaps/splashscreen.bmp",
51 parent, ID, title, style -- see wx.Frame
52 duration -- milliseconds to display the splash screen
53 bitmapfile -- absolute or relative pathname to image file
54 callback -- if specified, is called when timer completes, callback is
55 responsible for closing the splash screen
58 self
.bitmap
= bmp
= wx
.Image(bitmapfile
, wx
.BITMAP_TYPE_ANY
).ConvertToBitmap()
60 ### Determine size of bitmap to size window...
61 size
= (bmp
.GetWidth(), bmp
.GetHeight())
64 width
= wx
.SystemSettings_GetMetric(wx
.SYS_SCREEN_X
)
65 height
= wx
.SystemSettings_GetMetric(wx
.SYS_SCREEN_Y
)
66 pos
= ((width
-size
[0])/2, (height
-size
[1])/2)
68 # check for overflow...
70 size
= (wx
.SystemSettings_GetSystemMetric(wx
.SYS_SCREEN_X
), size
[1])
72 size
= (size
[0], wx
.SystemSettings_GetSystemMetric(wx
.SYS_SCREEN_Y
))
74 wx
.Frame
.__init
__(self
, parent
, ID
, title
, pos
, size
, style
)
75 self
.Bind(wx
.EVT_LEFT_DOWN
, self
.OnMouseClick
)
76 self
.Bind(wx
.EVT_CLOSE
, self
.OnCloseWindow
)
77 self
.Bind(wx
.EVT_PAINT
, self
.OnPaint
)
78 self
.Bind(wx
.EVT_ERASE_BACKGROUND
, self
.OnEraseBG
)
83 class SplashTimer(wx
.Timer
):
84 def __init__(self
, targetFunction
):
85 self
.Notify
= targetFunction
86 wx
.Timer
.__init
__(self
)
89 callback
= self
.OnSplashExitDefault
91 self
.timer
= SplashTimer(callback
)
92 self
.timer
.Start(duration
, 1) # one-shot only
94 def OnPaint(self
, event
):
96 dc
.DrawBitmap(self
.bitmap
, (0,0), False)
98 def OnEraseBG(self
, event
):
101 def OnSplashExitDefault(self
, event
=None):
104 def OnCloseWindow(self
, event
=None):
110 def OnMouseClick(self
, event
):
113 #----------------------------------------------------------------------
116 if __name__
== "__main__":
117 class DemoApp(wx
.App
):
119 wx
.InitAllImageHandlers()
120 self
.splash
= SplashScreen(None, bitmapfile
="splashscreen.jpg", callback
=self
.OnSplashExit
)
121 self
.splash
.Show(True)
122 self
.SetTopWindow(self
.splash
)
124 def OnSplashExit(self
, event
=None):
125 print "Yay! Application callback worked!"
126 self
.splash
.Close(True)
128 ### Build working windows here...
129 def test(sceneGraph
=None):