From: Youness Alaoui Date: Fri, 11 Sep 2015 20:45:55 +0000 (-0400) Subject: Revert "Removed splash screen" X-Git-Tag: lulzbot-17.04~10 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=0b811d51541c4eacaa621c6d6f5f118f840510b2;p=cura.git Revert "Removed splash screen" This reverts commit a9071456ab12e31eeec6b8e41dabf323774ca969. Fixes T229 #BringBackSplashScreen --- diff --git a/Cura/gui/app.py b/Cura/gui/app.py index cd5f3996..9e5e8de6 100644 --- a/Cura/gui/app.py +++ b/Cura/gui/app.py @@ -24,6 +24,7 @@ class CuraApp(wx.App): super(CuraApp, self).__init__(redirect=False) self.mainWindow = None + self.splash = None self.loadFiles = files if platform.system() == "Darwin": @@ -54,7 +55,12 @@ class CuraApp(wx.App): socketListener.daemon = True socketListener.start() - self.afterSplashCallback() + if sys.platform.startswith('darwin'): + #Do not show a splashscreen on OSX, as by Apple guidelines + self.afterSplashCallback() + else: + from Cura.gui import splashScreen + self.splash = splashScreen.splashScreen(self.afterSplashCallback) def MacOpenFile(self, path): try: @@ -93,6 +99,12 @@ class CuraApp(wx.App): except: pass + def destroySplashScreen(self): + if self.splash is not None: + self.splash.Show(False) + self.splash.Destroy() + self.splash = None + def afterSplashCallback(self): #These imports take most of the time and thus should be done after showing the splashscreen import webbrowser @@ -128,11 +140,13 @@ class CuraApp(wx.App): exampleFile = os.path.normpath(os.path.join(resources.resourceBasePath, 'example', 'Rocktopus.stl')) self.loadFiles = [exampleFile] + self.destroySplashScreen() configWizard.ConfigWizard() if profile.getPreference('check_for_updates') == 'True': newVersion = version.checkForNewerVersion() if newVersion is not None: + self.destroySplashScreen() if wx.MessageBox(_("A new version of Cura is available, would you like to download?"), _("New version available"), wx.YES_NO | wx.ICON_INFORMATION) == wx.YES: webbrowser.open(newVersion) return @@ -147,6 +161,7 @@ class CuraApp(wx.App): profile.performVersionUpgrade() self.mainWindow = mainWindow.mainWindow() + self.destroySplashScreen() self.SetTopWindow(self.mainWindow) self.mainWindow.Show() self.mainWindow.OnDropFiles(self.loadFiles) diff --git a/Cura/gui/splashScreen.py b/Cura/gui/splashScreen.py new file mode 100644 index 00000000..a3568a0d --- /dev/null +++ b/Cura/gui/splashScreen.py @@ -0,0 +1,26 @@ +__copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License" + +import wx._core #We only need the core here, which speeds up the import. As we want to show the splashscreen ASAP. + +from Cura.util.resources import getPathForImage + +class splashScreen(wx.SplashScreen): + def __init__(self, callback): + self.callback = callback + bitmap = wx.Bitmap(getPathForImage('splash.png')) + super(splashScreen, self).__init__(bitmap, wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT, 100, None) + # Add a timeout and call the callback in the close event to avoid having the callback called + # before the splashscreen paint events which could cause it not to appear or to appear as a grey + # rectangle while the app is loading + self.Bind(wx.EVT_CLOSE, self.OnClose) + + + def OnClose(self, e): + if self.callback: + # Avoid calling the callback twice + cb = self.callback + self.callback = None + # The callback will destroy us + wx.CallAfter(cb) + + e.Skip() diff --git a/resources/images/splash.png b/resources/images/splash.png new file mode 100644 index 00000000..b95c6a44 Binary files /dev/null and b/resources/images/splash.png differ