chiark / gitweb /
Added a loading splashscreen. (needs better artwork)
authordaid <daid303@gmail.com>
Thu, 30 Aug 2012 09:47:20 +0000 (11:47 +0200)
committerdaid <daid303@gmail.com>
Thu, 30 Aug 2012 09:47:20 +0000 (11:47 +0200)
Cura/cura.py
Cura/gui/mainWindow.py
Cura/gui/splashScreen.py [new file with mode: 0644]
Cura/images/splash.png [new file with mode: 0644]

index 2374f988ea9056dbd946a1bb5dc5498d5212bc64..215be473bd9fcd5b376d4fd3e1f0fef89fafdf2c 100644 (file)
@@ -73,8 +73,12 @@ def main():
        else:
                if len(args) > 0:
                        profile.putPreference('lastFile', ';'.join(args))
-               from gui import mainWindow
-               mainWindow.main()
+               from gui import splashScreen
+               splashScreen.showSplash(mainWindowRunCallback)
+
+def mainWindowRunCallback():
+       from gui import mainWindow
+       mainWindow.main()
 
 if __name__ == '__main__':
        main()
index 6822e680d0cc50fcf003ab25d38640c7a7b766cc..7523ce8906a92392b263113846562941b7cbd94f 100644 (file)
@@ -24,7 +24,7 @@ from util import version
 from util import sliceRun
 
 def main():
-       app = wx.App(False)
+       #app = wx.App(False)
        if profile.getPreference('wizardDone') == 'False':
                configWizard.configWizard()
                profile.putPreference("wizardDone", "True")
@@ -32,7 +32,7 @@ def main():
                simpleMode.simpleModeWindow()
        else:
                mainWindow()
-       app.MainLoop()
+       #app.MainLoop()
 
 class mainWindow(configBase.configWindowBase):
        "Main user interface window"
diff --git a/Cura/gui/splashScreen.py b/Cura/gui/splashScreen.py
new file mode 100644 (file)
index 0000000..276cc79
--- /dev/null
@@ -0,0 +1,36 @@
+import sys, os
+#We only need the core here, which speeds up the import. As we want to show the splashscreen ASAP.
+import wx._core
+
+def getBitmapImage(filename):
+       #The frozen executable has the script files in a zip, so we need to exit another level to get to our images.
+       if hasattr(sys, 'frozen'):
+               return wx.Bitmap(os.path.normpath(os.path.join(os.path.split(__file__)[0], "../../images", filename)))
+       else:
+               return wx.Bitmap(os.path.normpath(os.path.join(os.path.split(__file__)[0], "../images", filename)))
+
+class splashScreen(wx.SplashScreen):
+       def __init__(self, callback):
+               self.callback = callback
+               bitmap = getBitmapImage("splash.png")
+               super(splashScreen, self).__init__(bitmap, wx.SPLASH_CENTRE_ON_SCREEN, 0, None)
+               wx.CallAfter(callback)
+               wx.CallAfter(self.Destroy)
+
+def showSplash(callback):
+       app = wx.App(False)
+       splashScreen(callback)
+       app.MainLoop()
+
+def testCallback():
+       print "Callback!"
+       import time
+       time.sleep(2)
+       print "!Callback"
+
+def main():
+       showSplash(testCallback)
+
+if __name__ == u'__main__':
+       main()
+
diff --git a/Cura/images/splash.png b/Cura/images/splash.png
new file mode 100644 (file)
index 0000000..82bf83b
Binary files /dev/null and b/Cura/images/splash.png differ