]> git.saurik.com Git - wxWidgets.git/commitdiff
Added SplashScreen class from Mike Fletcher and use it in the demo.
authorRobin Dunn <robin@alldunn.com>
Sat, 20 Nov 1999 21:15:12 +0000 (21:15 +0000)
committerRobin Dunn <robin@alldunn.com>
Sat, 20 Nov 1999 21:15:12 +0000 (21:15 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4636 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

utils/wxPython/README.txt
utils/wxPython/demo/Main.py
utils/wxPython/demo/bitmaps/splash.gif [new file with mode: 0644]
utils/wxPython/lib/splashscreen.py [new file with mode: 0644]

index 11a9dfe6966b074c5ef066622e9dd2b3a532127d..668e3ac258a20783482549a010e1193d0e453927 100644 (file)
@@ -52,6 +52,11 @@ Updated wxMVCTree and added a demo for it.
 Added a wrapper class for the Visualization ToolKit (or VTK) in the
 wxPython.lib.vtk module.  (http://www.kitware.com/)
 
+Fixed wxTreeCtrl.SetItemImage and GetItemImage to recognise the new
+"which" parameter.
+
+Added wxPython.lib.spashscreen from Mike Fletcher.
+
 
 
 
index 3b474d0b0994f4758b8b6afa8fa1564ba5bfc4cb..f5292d51f0ed06f39a200a1574815ca26eddfe77 100644 (file)
@@ -13,7 +13,7 @@
 
 import sys, os
 from   wxPython.wx import *
-
+from   wxPython.lib.splashscreen import SplashScreen
 
 #---------------------------------------------------------------------------
 
@@ -355,7 +355,16 @@ class MyApp(wxApp):
         wxImage_AddHandler(wxJPEGHandler())
         wxImage_AddHandler(wxPNGHandler())
         wxImage_AddHandler(wxGIFHandler())
-        frame = wxPythonDemo(NULL, -1, "wxPython: (A Demonstration)")
+
+        self.splash = SplashScreen(None, bitmapfile='bitmaps/splash.gif',
+                              duration=4000, callback=self.AfterSplash)
+        self.splash.Show(true)
+        wxYield()
+        return true
+
+    def AfterSplash(self):
+        self.splash.Close(true)
+        frame = wxPythonDemo(None, -1, "wxPython: (A Demonstration)")
         frame.Show(true)
         self.SetTopWindow(frame)
         return true
diff --git a/utils/wxPython/demo/bitmaps/splash.gif b/utils/wxPython/demo/bitmaps/splash.gif
new file mode 100644 (file)
index 0000000..918c3a6
Binary files /dev/null and b/utils/wxPython/demo/bitmaps/splash.gif differ
diff --git a/utils/wxPython/lib/splashscreen.py b/utils/wxPython/lib/splashscreen.py
new file mode 100644 (file)
index 0000000..a5fade2
--- /dev/null
@@ -0,0 +1,112 @@
+#----------------------------------------------------------------------
+# Name:        wxPython.lib.splashscreen
+# Purpose:     A simple frame that can display a bitmap and closes itself
+#              after a specified timeout or a mouse click.
+#
+# Author:      Mike Fletcher, Robin Dunn
+#
+# Created:     19-Nov-1999
+# RCS-ID:      $Id$
+# Copyright:   (c) 1999 by Total Control Software
+# Licence:     wxWindows license
+#----------------------------------------------------------------------
+
+from wxPython.wx import *
+
+#----------------------------------------------------------------------
+
+def bitmapFromFile(filename):
+    '''Non-portable test for bitmap type...'''
+    import imghdr
+    BITMAPTYPEGUESSDICT = {
+        "bmp" :wxBITMAP_TYPE_BMP,
+        "png" :wxBITMAP_TYPE_PNG,
+        "jpeg":wxBITMAP_TYPE_JPEG,
+        "gif" :wxBITMAP_TYPE_GIF,
+        "xbm" :wxBITMAP_TYPE_XBM,
+    }
+    # following assumes bitmap type if we cannot resolve image type
+    typ = BITMAPTYPEGUESSDICT.get(imghdr.what(filename), wxBITMAP_TYPE_BMP)
+    bitmap = wxImage(filename, typ).ConvertToBitmap()
+    return bitmap
+
+#----------------------------------------------------------------------
+
+class SplashScreen(wxFrame):
+    def __init__(self, parent, ID=-1, title="SplashScreen", style=wxSTAY_ON_TOP,
+                 duration=1500, bitmapfile="bitmaps/splashscreen.bmp", callback = None):
+        '''
+        parent, ID, title, style -- see wxFrame
+        duration -- milliseconds to display the splash screen
+        bitmapfile -- absolute or relative pathname, extension used for type negotiation
+        callback -- if specified, is called when timer completes, callback is responsible for closing the splash screen
+        '''
+        ### Loading bitmap
+        self.bitmap = bmp = bitmapFromFile(bitmapfile)
+        ### Determine size of bitmap to size window...
+        size = (bmp.GetWidth(), bmp.GetHeight())
+        # size of screen
+        width = wxSystemSettings_GetSystemMetric(wxSYS_SCREEN_X)
+        height = wxSystemSettings_GetSystemMetric(wxSYS_SCREEN_Y)
+        pos = ((width-size[0])/2, (height-size[1])/2)
+
+        # check for overflow...
+        if pos[0] < 0:
+            size = (wxSystemSettings_GetSystemMetric(wxSYS_SCREEN_X), size[1])
+        if pos[1] < 0:
+            size = (size[0], wxSystemSettings_GetSystemMetric(wxSYS_SCREEN_Y))
+
+        wxFrame.__init__(self, parent, ID, title, pos, size, style)
+        self.Show(true)
+        dc = wxClientDC(self)
+        dc.DrawBitmap(self.bitmap, 0,0, false)
+
+        class SplashTimer(wxTimer):
+            def __init__(self, targetFunction):
+                self.Notify = targetFunction
+                wxTimer.__init__(self)
+
+        if callback is None:
+            callback = self.OnSplashExitDefault
+
+        self.timer = SplashTimer(callback)
+        self.timer.Start(duration, 1) # one-shot only
+        EVT_LEFT_DOWN(self, self.OnMouseClick)
+
+
+    def OnSplashExitDefault(self, event=None):
+        self.Close(true)
+
+
+    def OnCloseWindow(self, event=None):
+        self.Show(false)
+        self.timer.Stop()
+        del self.timer
+        self.Destroy()
+
+
+    def OnMouseClick(self, event):
+        self.timer.Notify()
+
+#----------------------------------------------------------------------
+
+
+if __name__ == "__main__":
+    class DemoApp(wxApp):
+        def OnInit(self):
+            wxImage_AddHandler(wxJPEGHandler())
+            wxImage_AddHandler(wxPNGHandler())
+            wxImage_AddHandler(wxGIFHandler())
+            self.splash = SplashScreen(NULL, bitmapfile="splashscreen.jpg", callback=self.OnSplashExit)
+            self.splash.Show(true)
+            self.SetTopWindow(self.splash)
+            return true
+        def OnSplashExit(self, event=None):
+            print "Yay! Application callback worked!"
+            self.splash.Close(true)
+            del self.splash
+            ### Build working windows here...
+    def test(sceneGraph=None):
+        app = DemoApp(0)
+        app.MainLoop()
+    test()