chiark / gitweb /
Fix the splashscreen overlaying on the first run wizard on mac.
[cura.git] / Cura / gui / splashScreen.py
1 import sys, os
2 #We only need the core here, which speeds up the import. As we want to show the splashscreen ASAP.
3 import wx._core
4
5 def getBitmapImage(filename):
6         #The frozen executable has the script files in a zip, so we need to exit another level to get to our images.
7         if hasattr(sys, 'frozen'):
8                 return wx.Bitmap(os.path.normpath(os.path.join(os.path.split(__file__)[0], "../../images", filename)))
9         else:
10                 return wx.Bitmap(os.path.normpath(os.path.join(os.path.split(__file__)[0], "../images", filename)))
11
12 class splashScreen(wx.SplashScreen):
13         def __init__(self, callback):
14                 self.callback = callback
15                 bitmap = getBitmapImage("splash.png")
16                 super(splashScreen, self).__init__(bitmap, wx.SPLASH_CENTRE_ON_SCREEN, 0, None)
17                 wx.CallAfter(self.DoCallback)
18         
19         def DoCallback(self):
20                 self.callback(self)
21                 self.Destroy()
22
23 def showSplash(callback):
24         app = wx.App(False)
25         splashScreen(callback)
26         app.MainLoop()
27
28 def testCallback(splashscreen):
29         print "Callback!"
30         import time
31         time.sleep(2)
32         print "!Callback"
33
34 def main():
35         showSplash(testCallback)
36
37 if __name__ == u'__main__':
38         main()
39