1 from __future__ import absolute_import
10 #Only import the _core to save import time
13 class CuraApp(wx.App):
15 if platform.system() == "Windows" and not 'PYCHARM_HOSTED' in os.environ:
16 super(CuraApp, self).__init__(redirect = True, filename = 'output.txt')
18 super(CuraApp, self).__init__(redirect = False)
20 self.mainWindow = None
23 if sys.platform.startswith('darwin'):
24 #Do not show a splashscreen on OSX, as by Apple guidelines
25 self.afterSplashCallback()
27 from Cura.gui import splashScreen
28 self.splash = splashScreen.splashScreen(self.afterSplashCallback)
30 def MacOpenFile(self, path):
32 self.mainWindow._loadModels([path])
33 except Exception as e:
34 warnings.warn("File at {p} cannot be read: {e}".format(p=path, e=str(e)))
36 def afterSplashCallback(self):
37 #These imports take most of the time and thus should be done after showing the splashscreen
39 from Cura.gui import mainWindow
40 from Cura.gui import configWizard
41 from Cura.util import profile
42 from Cura.util import resources
43 from Cura.util import version
45 #If we haven't run it before, run the configuration wizard.
46 if profile.getPreference('machine_type') == 'unknown':
47 if platform.system() == "Darwin":
48 #Check if we need to copy our examples
49 exampleFile = os.path.expanduser('~/CuraExamples/UltimakerRobot_support.stl')
50 if not os.path.isfile(exampleFile):
52 os.makedirs(os.path.dirname(exampleFile))
55 for filename in glob.glob(os.path.normpath(os.path.join(resources.resourceBasePath, 'example', '*.*'))):
56 shutil.copy(filename, os.path.join(os.path.dirname(exampleFile), os.path.basename(filename)))
57 profile.putPreference('lastFile', exampleFile)
58 configWizard.configWizard()
60 #Hide the splashscreen before showing the main window.
61 if self.splash is not None:
62 self.splash.Show(False)
63 if profile.getPreference('check_for_updates') == 'True':
64 newVersion = version.checkForNewerVersion()
65 if newVersion is not None:
66 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:
67 webbrowser.open(newVersion)
69 self.mainWindow = mainWindow.mainWindow()
71 setFullScreenCapable(self.mainWindow)
73 if platform.system() == "Darwin":
75 _objc = ctypes.PyDLL(objc._objc.__file__)
77 # PyObject *PyObjCObject_New(id objc_object, int flags, int retain)
78 _objc.PyObjCObject_New.restype = ctypes.py_object
79 _objc.PyObjCObject_New.argtypes = [ctypes.c_void_p, ctypes.c_int, ctypes.c_int]
81 def setFullScreenCapable(frame):
82 frameobj = _objc.PyObjCObject_New(frame.GetHandle(), 0, 1)
84 NSWindowCollectionBehaviorFullScreenPrimary = 1<<7
85 window = frameobj.window()
86 newBehavior = window.collectionBehavior() | NSWindowCollectionBehaviorFullScreenPrimary
87 window.setCollectionBehavior_(newBehavior)
90 def setFullScreenCapable(frame):