diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 7b65601e..e8729a07 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -14,6 +14,7 @@ import random import simplejson as json import lzma import threading +import shutil from stat import S_IREAD, S_IRGRP, S_IROTH import subprocess @@ -100,6 +101,9 @@ class App(QtCore.QObject): version = 8.94 version_date = "2019/08/31" beta = True + # make this True is you want to create a portable app - that is, to save the settings files + # in the working directory + portable = True # current date now date = str(datetime.today()).rpartition('.')[0] @@ -205,8 +209,11 @@ class App(QtCore.QObject): App.log.debug("Win32!") else: App.log.debug("Win64!") + if self.portable is False: + self.data_path = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, None, 0) + '\FlatCAM' + else: + self.data_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) - self.data_path = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, None, 0) + '\FlatCAM' self.os = 'windows' else: # Linux/Unix/MacOS self.data_path = os.path.expanduser('~') + '/.FlatCAM' @@ -232,6 +239,13 @@ class App(QtCore.QObject): f = open(self.data_path + '/current_defaults.FlatConfig') f.close() except IOError: + if sys.platform == 'win32': + # this happen only once, at the first launch of the app. + # I use this to copy the vispy data files to the APPDATA folder, for Windows + source_path = self.data_path + '\\vispy\\data' + target_path = os.getenv('APPDATA') + '\\vispy' + self.copy_and_overwrite(from_path=source_path, to_path=target_path) + App.log.debug('Creating empty current_defaults.FlatConfig') f = open(self.data_path + '/current_defaults.FlatConfig', 'w') json.dump({}, f) @@ -2103,6 +2117,19 @@ class App(QtCore.QObject): except Exception as e: log.debug("Could not open FlatCAM Script file as App parameter due: %s" % str(e)) + @staticmethod + def copy_and_overwrite(from_path, to_path): + """ + From here: + https://stackoverflow.com/questions/12683834/how-to-copy-directory-recursively-in-python-and-overwrite-all + :param from_path: source path + :param to_path: destination path + :return: None + """ + if os.path.exists(to_path): + shutil.rmtree(to_path) + shutil.copytree(from_path, to_path) + def set_ui_title(self, name): self.ui.setWindowTitle('FlatCAM %s %s - %s %s' % (self.version, diff --git a/README.md b/README.md index 719c7b07..fcf1f9e0 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,10 @@ CAD program, and create G-Code for Isolation routing. - added Edit -> Preferences GUI and storage for the Excellon Editor Add Slots - added a confirmation message for objects delete and a setting to activate it in Edit -> Preferences -> Global +- merged pull request from Mike Smith which fix an application crash when attempting to open a not-a-FlatCAM-project file as project +- merged pull request from Mike Smith that add support for a new SVG element: +- stored inside FlatCAM app the VisPy data files and at the first start the application will try to copy those files to the APPDATA (roaming) folder in case of running under Windows +- created an app 'switch' named 'self.portable' which when set True it will 'cx-freeze' an portable application 14.08.2019 diff --git a/flatcamGUI/VisPyData/data/fonts/opensans-regular.ttf b/flatcamGUI/VisPyData/data/fonts/opensans-regular.ttf new file mode 100644 index 00000000..db433349 Binary files /dev/null and b/flatcamGUI/VisPyData/data/fonts/opensans-regular.ttf differ diff --git a/flatcamGUI/VisPyData/data/freetype/freetype253.dll b/flatcamGUI/VisPyData/data/freetype/freetype253.dll new file mode 100644 index 00000000..3d49e2cd Binary files /dev/null and b/flatcamGUI/VisPyData/data/freetype/freetype253.dll differ diff --git a/flatcamGUI/VisPyData/data/freetype/freetype253_x64.dll b/flatcamGUI/VisPyData/data/freetype/freetype253_x64.dll new file mode 100644 index 00000000..7fce483f Binary files /dev/null and b/flatcamGUI/VisPyData/data/freetype/freetype253_x64.dll differ diff --git a/make_win.py b/make_win.py index 6b9029d3..4e5986b3 100644 --- a/make_win.py +++ b/make_win.py @@ -55,6 +55,7 @@ if platform.architecture()[0] == '64bit': include_files.append(("locale", "lib/locale")) include_files.append(("postprocessors", "lib/postprocessors")) include_files.append(("share", "lib/share")) +include_files.append(("flatcamGUI/VisPyData", "lib/vispy")) include_files.append(("README.md", "README.md")) include_files.append(("LICENSE", "LICENSE"))