1 from __future__ import absolute_import
10 #Only import the _core to save import time
13 from Cura.util import profile
15 class CuraApp(wx.App):
17 if platform.system() == "Windows":
18 super(CuraApp, self).__init__(redirect = True, filename = 'output.txt')
20 super(CuraApp, self).__init__(redirect = False)
22 self.mainWindow = None
25 if sys.platform.startswith('darwin'):
26 #Do not show a splashscreen on OSX, as by Apple guidelines
27 self.afterSplashCallback()
29 from Cura.gui import splashScreen
30 self.splash = splashScreen.splashScreen(self.afterSplashCallback)
32 def MacOpenFile(self, path):
34 self.mainWindow._loadModels([path])
35 except Exception as e:
36 warnings.warn("File at {p} cannot be read: {e}".format(p=path, e=str(e)))
38 def afterSplashCallback(self):
39 #These imports take most of the time and thus should be done after showing the splashscreen
40 from Cura.gui import mainWindow
41 from Cura.gui import configWizard
43 #If we haven't run it before, run the configuration wizard.
44 if profile.getPreference('machine_type') == 'unknown':
45 if platform.system() == "Darwin":
46 #Check if we need to copy our examples
47 exampleFile = os.path.expanduser('~/CuraExamples/UltimakerRobot_support.stl')
48 if not os.path.isfile(exampleFile):
50 os.makedirs(os.path.dirname(exampleFile))
53 for filename in glob.glob(os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'example', '*.*'))):
54 shutil.copy(filename, os.path.join(os.path.dirname(exampleFile), os.path.basename(filename)))
55 profile.putPreference('lastFile', exampleFile)
56 configWizard.configWizard()
58 #Hide the splashscreen before showing the main window.
59 if self.splash is not None:
60 self.splash.Show(False)
61 self.mainWindow = mainWindow.mainWindow()