[GRASS-SVN] r64489 - grass/trunk/gui/wxpython

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Feb 7 00:43:31 PST 2015


Author: martinl
Date: 2015-02-07 00:43:31 -0800 (Sat, 07 Feb 2015)
New Revision: 64489

Modified:
   grass/trunk/gui/wxpython/wxgui.py
Log:
wxGUI: new version of splash screen (based http://wiki.wxpython.org/SplashScreen)


Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py	2015-02-06 23:08:09 UTC (rev 64488)
+++ grass/trunk/gui/wxpython/wxgui.py	2015-02-07 08:43:31 UTC (rev 64489)
@@ -5,9 +5,9 @@
 
 Classes:
  - wxgui::GMApp
- - wxgui::Usage
+ - wxgui::GSplashScreen
 
-(C) 2006-2011 by the GRASS Development Team
+(C) 2006-2015 by the GRASS Development Team
 
 This program is free software under the GNU General Public License
 (>=v2). Read the file COPYING that comes with GRASS for details.
@@ -58,36 +58,38 @@
         if not globalvar.CheckWxVersion([2, 9]):
             wx.InitAllImageHandlers()
 
-        # create splash screen
-        introImagePath = os.path.join(globalvar.IMGDIR, "splash_screen.png")
-        introImage     = wx.Image(introImagePath, wx.BITMAP_TYPE_PNG)
-        introBmp       = introImage.ConvertToBitmap()
-        if SC and sys.platform != 'darwin':
-            # AdvancedSplash is buggy on the Mac as of 2.8.12.1
-            # and raises annoying (though seemingly harmless) errors everytime the GUI is started
-            splash = SC.AdvancedSplash(bitmap = introBmp,
-                                       timeout = 2000, parent = None, id = wx.ID_ANY)
-            splash.SetText(_('Starting GRASS GUI...'))
-            splash.SetTextColour(wx.Colour(45, 52, 27))
-            splash.SetTextFont(wx.Font(pointSize = 15, family = wx.DEFAULT, style = wx.NORMAL,
-                                       weight = wx.BOLD))
-            splash.SetTextPosition((150, 430))
-        else:
-            wx.SplashScreen (bitmap = introBmp, splashStyle = wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT,
-                             milliseconds = 2000, parent = None, id = wx.ID_ANY)
+        splash = GSplashScreen(app=self, workspace=self.workspaceFile)
+        splash.Show()
+        
+        return True
 
+class GSplashScreen(wx.SplashScreen):
+    """Create a splash screen widget
+    """
+    def __init__(self, parent=None, app=None, workspace=None):
+        self.workspaceFile = workspace
+        self.parent = parent
+        self.app = app
+        
+        bitmap = wx.Image(name=os.path.join(globalvar.IMGDIR, "splash_screen.png")).ConvertToBitmap()
+        wx.SplashScreen.__init__(self, bitmap,
+                                 wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT,
+                                 1000, parent)
+        self.Bind(wx.EVT_CLOSE, self.OnExit)
+
         wx.Yield()
 
+    def OnExit(self, event):
+        self.Hide()
+        
         # create and show main frame
-        mainframe = GMFrame(parent = None, id = wx.ID_ANY,
-                            workspace = self.workspaceFile)
+        frame = GMFrame(parent = None, id = wx.ID_ANY,
+                        workspace = self.workspaceFile)
+        self.app.SetTopWindow(frame)
+        frame.Show()
+        
+        event.Skip()  # make sure the default handler runs too
 
-        mainframe.Show()
-        self.SetTopWindow(mainframe)
-
-        return True
-
-
 def printHelp():
     """ Print program help"""
     print >> sys.stderr, "Usage:"
@@ -114,7 +116,6 @@
 
 
 def main(argv = None):
-
     if argv is None:
         argv = sys.argv
     try:



More information about the grass-commit mailing list