Initial subclass of wx.App and removing splash on Mac OS X.
parent
0a1b1c419a
commit
1d42ce8afc
53
Cura/cura.py
53
Cura/cura.py
|
@ -10,8 +10,12 @@ The slicing code is the same as Skeinforge. But the UI has been revamped to be..
|
||||||
"""
|
"""
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import warnings
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
|
||||||
|
import wx._core
|
||||||
|
|
||||||
from util import profile
|
from util import profile
|
||||||
|
|
||||||
__author__ = 'Daid'
|
__author__ = 'Daid'
|
||||||
|
@ -41,6 +45,14 @@ Art of Illusion <http://www.artofillusion.org/>"""
|
||||||
|
|
||||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||||
|
|
||||||
|
|
||||||
|
class CuraApp(wx.App):
|
||||||
|
def MacOpenFile(self, path):
|
||||||
|
try:
|
||||||
|
pass
|
||||||
|
except Exception as e:
|
||||||
|
warnings.warn("File at {p} cannot be read: {e}".format(p=path, e=str(e)))
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = OptionParser(usage="usage: %prog [options] <filename>.stl")
|
parser = OptionParser(usage="usage: %prog [options] <filename>.stl")
|
||||||
parser.add_option("-i", "--ini", action="store", type="string", dest="profileini",
|
parser.add_option("-i", "--ini", action="store", type="string", dest="profileini",
|
||||||
|
@ -56,42 +68,43 @@ def main():
|
||||||
parser.add_option("-s", "--slice", action="store_true", dest="slice",
|
parser.add_option("-s", "--slice", action="store_true", dest="slice",
|
||||||
help="Slice the given files instead of opening them in Cura")
|
help="Slice the given files instead of opening them in Cura")
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
if options.profile != None:
|
|
||||||
|
if options.profile is not None:
|
||||||
profile.loadGlobalProfileFromString(options.profile)
|
profile.loadGlobalProfileFromString(options.profile)
|
||||||
if options.profileini != None:
|
if options.profileini is not None:
|
||||||
profile.loadGlobalProfile(options.profileini)
|
profile.loadGlobalProfile(options.profileini)
|
||||||
if options.openprojectplanner != None:
|
|
||||||
|
if options.openprojectplanner is not None:
|
||||||
from gui import projectPlanner
|
from gui import projectPlanner
|
||||||
|
|
||||||
projectPlanner.main()
|
projectPlanner.main()
|
||||||
return
|
elif options.openflatslicer is not None:
|
||||||
if options.openflatslicer != None:
|
|
||||||
from gui import flatSlicerWindow
|
from gui import flatSlicerWindow
|
||||||
|
|
||||||
flatSlicerWindow.main()
|
flatSlicerWindow.main()
|
||||||
return
|
elif options.printfile is not None:
|
||||||
if options.printfile != None:
|
|
||||||
from gui import printWindow
|
from gui import printWindow
|
||||||
|
|
||||||
printWindow.startPrintInterface(options.printfile)
|
printWindow.startPrintInterface(options.printfile)
|
||||||
return
|
elif options.slice is not None:
|
||||||
|
|
||||||
if options.slice != None:
|
|
||||||
from util import sliceRun
|
from util import sliceRun
|
||||||
|
|
||||||
sliceRun.runSlice(args)
|
sliceRun.runSlice(args)
|
||||||
else:
|
else:
|
||||||
if len(args) > 0:
|
if len(args) > 0:
|
||||||
profile.putPreference('lastFile', ';'.join(args))
|
profile.putPreference('lastFile', ';'.join(args))
|
||||||
|
|
||||||
from gui import splashScreen
|
from gui import splashScreen
|
||||||
|
|
||||||
splashScreen.showSplash(mainWindowRunCallback)
|
def mainWindowRunCallback(splash):
|
||||||
|
from gui import mainWindow
|
||||||
|
if splash is not None:
|
||||||
|
splash.Show(False)
|
||||||
|
mainWindow.main()
|
||||||
|
|
||||||
|
app = CuraApp(False)
|
||||||
def mainWindowRunCallback(splash):
|
# Apple discurage usage of splash screens on a mac.
|
||||||
from gui import mainWindow
|
if sys.platform.startswith('darwin'):
|
||||||
|
mainWindowRunCallback(None)
|
||||||
mainWindow.main(splash)
|
else:
|
||||||
|
splashScreen.splashScreen(mainWindowRunCallback)
|
||||||
|
app.MainLoop()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -25,7 +25,7 @@ from util import version
|
||||||
from util import sliceRun
|
from util import sliceRun
|
||||||
from util import meshLoader
|
from util import meshLoader
|
||||||
|
|
||||||
def main(splash):
|
def main():
|
||||||
#app = wx.App(False)
|
#app = wx.App(False)
|
||||||
if profile.getPreference('machine_type') == 'unknown':
|
if profile.getPreference('machine_type') == 'unknown':
|
||||||
if platform.system() == "Darwin":
|
if platform.system() == "Darwin":
|
||||||
|
@ -39,7 +39,6 @@ def main(splash):
|
||||||
for filename in glob.glob(os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'example', '*.*'))):
|
for filename in glob.glob(os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'example', '*.*'))):
|
||||||
shutil.copy(filename, os.path.join(os.path.dirname(exampleFile), os.path.basename(filename)))
|
shutil.copy(filename, os.path.join(os.path.dirname(exampleFile), os.path.basename(filename)))
|
||||||
profile.putPreference('lastFile', exampleFile)
|
profile.putPreference('lastFile', exampleFile)
|
||||||
splash.Show(False)
|
|
||||||
configWizard.configWizard()
|
configWizard.configWizard()
|
||||||
if profile.getPreference('startMode') == 'Simple':
|
if profile.getPreference('startMode') == 'Simple':
|
||||||
simpleMode.simpleModeWindow()
|
simpleMode.simpleModeWindow()
|
||||||
|
|
|
@ -19,7 +19,8 @@ class splashScreen(wx.SplashScreen):
|
||||||
|
|
||||||
|
|
||||||
def showSplash(callback):
|
def showSplash(callback):
|
||||||
app = wx.App(False)
|
from Cura.cura import CuraApp
|
||||||
|
app = CuraApp(False)
|
||||||
splashScreen(callback)
|
splashScreen(callback)
|
||||||
app.MainLoop()
|
app.MainLoop()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue