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