diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 094b2153..416596b0 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -2050,7 +2050,8 @@ class App(QtCore.QObject): 'mirror', 'ncc', 'ncc_clear', 'ncr', 'new', 'new_geometry', 'non_copper_regions', 'offset', 'open_excellon', 'open_gcode', 'open_gerber', 'open_project', 'options', 'paint', - 'pan', 'panel', 'panelize', 'plot_all', 'plot_objects', 'save', 'save_project', + 'pan', 'panel', 'panelize', 'plot_all', 'plot_objects', 'quit_flatcam', + 'save', 'save_project', 'save_sys', 'scale', 'set_active', 'set_sys', 'setsys', 'skew', 'subtract_poly', 'subtract_rectangle', 'version', 'write_gcode' @@ -4536,21 +4537,27 @@ class App(QtCore.QObject): self.save_defaults() log.debug("App.final_save() --> App Defaults saved.") - # save toolbar state to file - settings = QSettings("Open Source", "FlatCAM") - settings.setValue('saved_gui_state', self.ui.saveState()) - settings.setValue('maximized_gui', self.ui.isMaximized()) - settings.setValue('language', self.ui.general_defaults_form.general_app_group.language_cb.get_value()) - settings.setValue('notebook_font_size', - self.ui.general_defaults_form.general_gui_set_group.notebook_font_size_spinner.get_value()) - settings.setValue('axis_font_size', - self.ui.general_defaults_form.general_gui_set_group.axis_font_size_spinner.get_value()) - settings.setValue('textbox_font_size', - self.ui.general_defaults_form.general_gui_set_group.textbox_font_size_spinner.get_value()) - settings.setValue('toolbar_lock', self.ui.lock_action.isChecked()) + if self.cmd_line_headless != 1: + # save app state to file + settings = QSettings("Open Source", "FlatCAM") + settings.setValue('saved_gui_state', self.ui.saveState()) + settings.setValue('maximized_gui', self.ui.isMaximized()) + settings.setValue('language', self.ui.general_defaults_form.general_app_group.language_cb.get_value()) + settings.setValue( + 'notebook_font_size', + self.ui.general_defaults_form.general_gui_set_group.notebook_font_size_spinner.get_value() + ) + settings.setValue('axis_font_size', + self.ui.general_defaults_form.general_gui_set_group.axis_font_size_spinner.get_value()) + settings.setValue( + 'textbox_font_size', + self.ui.general_defaults_form.general_gui_set_group.textbox_font_size_spinner.get_value() + ) + settings.setValue('toolbar_lock', self.ui.lock_action.isChecked()) + + # This will write the setting to the platform specific storage. + del settings - # This will write the setting to the platform specific storage. - del settings log.debug("App.final_save() --> App UI state saved.") QtWidgets.qApp.quit() diff --git a/README.md b/README.md index 7d454e37..ce1aac70 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ CAD program, and create G-Code for Isolation routing. - added control over the display of Sys Tray Icon in Edit -> Preferences -> General -> GUI Settings -> Sys Tray Icon checkbox - updated some of the default values to more reasonable ones - FlatCAM can be run in HEADLESS mode now. This node can be selected by using the --headless=1 command line argument or by changing the line headless=False to True in config/configuration.txt file. In this mod the Sys Tray Icon menu will hold only the Run Scrip menu entry and Exit entry. +- added a new TclCommand named quit_flatcam which will ... quit FlatCAM from Tcl Shell or from a script 18.09.2019 diff --git a/tclCommands/TclCommandQuit.py b/tclCommands/TclCommandQuit.py new file mode 100644 index 00000000..9d1c84d5 --- /dev/null +++ b/tclCommands/TclCommandQuit.py @@ -0,0 +1,47 @@ +from ObjectCollection import * +from tclCommands.TclCommand import TclCommand + + +class TclCommandQuit(TclCommand): + """ + Tcl shell command to quit FlatCAM from Tcl shell. + + example: + + """ + + # List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon) + aliases = ['quit_flatcam'] + + # Dictionary of types from Tcl command, needs to be ordered + arg_names = collections.OrderedDict([ + + ]) + + # Dictionary of types from Tcl command, needs to be ordered , this is for options like -optionname value + option_types = collections.OrderedDict([ + + ]) + + # array of mandatory options for current Tcl command: required = {'name','outname'} + required = [] + + # structured help for current command, args needs to be ordered + help = { + 'main': "Tcl shell command to quit FlatCAM from Tcl shell.", + 'args': collections.OrderedDict([ + + ]), + 'examples': ['quit_flatcam'] + } + + def execute(self, args, unnamed_args): + """ + + :param args: + :param unnamed_args: + :return: + """ + + self.app.quit_application() + diff --git a/tclCommands/__init__.py b/tclCommands/__init__.py index 98603aa5..1c7ac5b9 100644 --- a/tclCommands/__init__.py +++ b/tclCommands/__init__.py @@ -48,6 +48,7 @@ import tclCommands.TclCommandPaint import tclCommands.TclCommandPanelize import tclCommands.TclCommandPlotAll import tclCommands.TclCommandPlotObjects +import tclCommands.TclCommandQuit import tclCommands.TclCommandSaveProject import tclCommands.TclCommandSaveSys import tclCommands.TclCommandScale