Esempio n. 1
0
def main():
	parser = OptionParser(usage="usage: %prog [options] <filename>.stl")
	parser.add_option("-i", "--ini", action="store", type="string", dest="profileini",
		help="Load settings from a profile ini file")
	parser.add_option("-P", "--project", action="store_true", dest="openprojectplanner",
		help="Open the project planner")
	parser.add_option("-F", "--flat", action="store_true", dest="openflatslicer",
		help="Open the 2D SVG slicer (unfinished)")
	parser.add_option("-r", "--print", action="store", type="string", dest="printfile",
		help="Open the printing interface, instead of the normal cura interface.")
	parser.add_option("-p", "--profile", action="store", type="string", dest="profile",
		help="Internal option, do not use!")
	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 is not None:
		profile.loadGlobalProfileFromString(options.profile)
	if options.profileini is not None:
		profile.loadGlobalProfile(options.profileini)

	if options.openprojectplanner is not None:
		from Cura.gui import projectPlanner
		projectPlanner.main()
	elif options.openflatslicer is not None:
		from Cura.gui import flatSlicerWindow
		flatSlicerWindow.main()
	elif options.printfile is not None:
		from Cura.gui import printWindow
		printWindow.startPrintInterface(options.printfile)
	elif options.slice is not None:
		from Cura.util import sliceRun
		sliceRun.runSlice(args)
	else:
		if len(args) > 0:
			profile.putPreference('lastFile', ';'.join(args))

		import wx._core
		from Cura.gui import splashScreen

		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 mainWindowRunCallback(splash):
			from Cura.gui import mainWindow
			if splash is not None:
				splash.Show(False)
			mainWindow.main()

		app = CuraApp(False)
		# Apple discourages usage of splash screens on a mac.
		if sys.platform.startswith('darwin'):
			mainWindowRunCallback(None)
		else:
			splashScreen.splashScreen(mainWindowRunCallback)
		app.MainLoop()
Esempio n. 2
0
    def __init__(self, files):
        if platform.system(
        ) == "Windows" and not 'PYCHARM_HOSTED' in os.environ:
            from Cura.util import profile
            super(CuraApp,
                  self).__init__(redirect=True,
                                 filename=os.path.join(profile.getBasePath(),
                                                       'output_log.txt'))
        else:
            super(CuraApp, self).__init__(redirect=False)

        self.mainWindow = None
        self.splash = None
        self.loadFiles = files

        if platform.system() == "Darwin":
            self.Bind(wx.EVT_ACTIVATE_APP, self.OnActivate)

        if sys.platform.startswith('win'):
            #Check for an already running instance, if another instance is running load files in there
            from Cura.util import version
            from ctypes import windll
            import ctypes
            import socket
            import threading

            portNr = 0xCA00 + sum(map(ord, version.getVersion(False)))
            if len(files) > 0:
                try:
                    other_hwnd = windll.user32.FindWindowA(
                        None,
                        ctypes.c_char_p('Cura - ' + version.getVersion()))
                    if other_hwnd != 0:
                        sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
                        sock.sendto('\0'.join(files), ("127.0.0.1", portNr))

                        windll.user32.SetForegroundWindow(other_hwnd)
                        return
                except:
                    pass

            socketListener = threading.Thread(target=self.Win32SocketListener,
                                              args=(portNr, ))
            socketListener.daemon = True
            socketListener.start()

        if sys.platform.startswith('darwin'):
            #Do not show a splashscreen on OSX, as by Apple guidelines
            self.afterSplashCallback()
        else:
            from Cura.gui import splashScreen
            self.splash = splashScreen.splashScreen(self.afterSplashCallback)
Esempio n. 3
0
	def __init__(self):
		if platform.system() == "Windows":
			super(CuraApp, self).__init__(redirect = True, filename = 'output.txt')
		else:
			super(CuraApp, self).__init__(redirect = False)

		self.mainWindow = None
		self.splash = None

		if sys.platform.startswith('darwin'):
			#Do not show a splashscreen on OSX, as by Apple guidelines
			self.afterSplashCallback()
		else:
			self.splash = splashScreen.splashScreen(self.afterSplashCallback)
Esempio n. 4
0
	def __init__(self, files):
		if platform.system() == "Windows" and not 'PYCHARM_HOSTED' in os.environ:
			super(CuraApp, self).__init__(redirect = True, filename = 'output.txt')
		else:
			super(CuraApp, self).__init__(redirect = False)

		self.mainWindow = None
		self.splash = None
		self.loadFiles = files

		if sys.platform.startswith('darwin'):
			#Do not show a splashscreen on OSX, as by Apple guidelines
			self.afterSplashCallback()
		else:
			from Cura.gui import splashScreen
			self.splash = splashScreen.splashScreen(self.afterSplashCallback)
Esempio n. 5
0
	def __init__(self, files):
		if platform.system() == "Windows" and not 'PYCHARM_HOSTED' in os.environ:
			from Cura.util import profile
			super(CuraApp, self).__init__(redirect=True, filename=os.path.join(profile.getBasePath(), 'output_log.txt'))
		else:
			super(CuraApp, self).__init__(redirect=False)

		self.mainWindow = None
		self.splash = None
		self.loadFiles = files

		self.Bind(wx.EVT_ACTIVATE_APP, self.OnActivate)

		if sys.platform.startswith('win'):
			#Check for an already running instance, if another instance is running load files in there
			from Cura.util import version
			from ctypes import windll
			import ctypes
			import socket
			import threading

			portNr = 0xCA00 + sum(map(ord, version.getVersion(False)))
			if len(files) > 0:
				try:
					other_hwnd = windll.user32.FindWindowA(None, ctypes.c_char_p('Cura - ' + version.getVersion()))
					if other_hwnd != 0:
						sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
						sock.sendto('\0'.join(files), ("127.0.0.1", portNr))

						windll.user32.SetForegroundWindow(other_hwnd)
						return
				except:
					pass

			socketListener = threading.Thread(target=self.Win32SocketListener, args=(portNr,))
			socketListener.daemon = True
			socketListener.start()

		# if sys.platform.startswith('darwin'):
		# 	#Do not show a splashscreen on OSX, as by Apple guidelines
		# 	self.afterSplashCallback()
		# else:
		# 	from Cura.gui import splashScreen
		# 	self.splash = splashScreen.splashScreen(self.afterSplashCallback)
		from Cura.gui import splashScreen
		self.splash = splashScreen.splashScreen(self.afterSplashCallback)
Esempio n. 6
0
	def __init__(self, files):
		from Cura.util import resources
		from Cura.util import version
		brand = version.getBrand()
		resources.setupLocalization(brand)

		if not version.isDevVersion():
			super(CuraApp, self).__init__(redirect = True, filename = 'output.txt')
		else:
			super(CuraApp, self).__init__(redirect = False)
		self.mainWindow = None
		self.splash = None
		self.loadFiles = files

		# if sys.platform.startswith('darwin'):
		# 	Do not show a splashscreen on OSX, as by Apple guidelines
			# self.afterSplashCallback()
		# else:
		from Cura.gui import splashScreen
		self.splash = splashScreen.splashScreen(self.afterSplashCallback)