Initial subclass of wx.App and removing splash on Mac OS X.

master
Ilya Kulakov 2012-12-05 23:54:11 +07:00
parent 0a1b1c419a
commit 1d42ce8afc
3 changed files with 64 additions and 51 deletions

View File

@ -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
import sys
import warnings
from optparse import OptionParser
import wx._core
from util import profile
__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'
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():
parser = OptionParser(usage="usage: %prog [options] <filename>.stl")
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",
help="Slice the given files instead of opening them in Cura")
(options, args) = parser.parse_args()
if options.profile != None:
if options.profile is not None:
profile.loadGlobalProfileFromString(options.profile)
if options.profileini != None:
if options.profileini is not None:
profile.loadGlobalProfile(options.profileini)
if options.openprojectplanner != None:
if options.openprojectplanner is not None:
from gui import projectPlanner
projectPlanner.main()
return
if options.openflatslicer != None:
elif options.openflatslicer is not None:
from gui import flatSlicerWindow
flatSlicerWindow.main()
return
if options.printfile != None:
elif options.printfile is not None:
from gui import printWindow
printWindow.startPrintInterface(options.printfile)
return
if options.slice != None:
elif options.slice is not None:
from util import sliceRun
sliceRun.runSlice(args)
else:
if len(args) > 0:
profile.putPreference('lastFile', ';'.join(args))
from gui import splashScreen
splashScreen.showSplash(mainWindowRunCallback)
def mainWindowRunCallback(splash):
from gui import mainWindow
if splash is not None:
splash.Show(False)
mainWindow.main()
def mainWindowRunCallback(splash):
from gui import mainWindow
mainWindow.main(splash)
app = CuraApp(False)
# Apple discurage usage of splash screens on a mac.
if sys.platform.startswith('darwin'):
mainWindowRunCallback(None)
else:
splashScreen.splashScreen(mainWindowRunCallback)
app.MainLoop()
if __name__ == '__main__':
main()

View File

@ -25,7 +25,7 @@ from util import version
from util import sliceRun
from util import meshLoader
def main(splash):
def main():
#app = wx.App(False)
if profile.getPreference('machine_type') == 'unknown':
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', '*.*'))):
shutil.copy(filename, os.path.join(os.path.dirname(exampleFile), os.path.basename(filename)))
profile.putPreference('lastFile', exampleFile)
splash.Show(False)
configWizard.configWizard()
if profile.getPreference('startMode') == 'Simple':
simpleMode.simpleModeWindow()

View File

@ -19,7 +19,8 @@ class splashScreen(wx.SplashScreen):
def showSplash(callback):
app = wx.App(False)
from Cura.cura import CuraApp
app = CuraApp(False)
splashScreen(callback)
app.MainLoop()