diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 3841b963..f15284ac 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -2257,6 +2257,7 @@ class App(QtCore.QObject): # reference for the self.ui.code_editor self.reference_code_editor = None + self.script_code = '' # if Preferences are changed in the Edit -> Preferences tab the value will be set to True self.preferences_changed_flag = False @@ -5918,11 +5919,11 @@ class App(QtCore.QObject): if self.ui.shell_dock.isHidden(): self.ui.shell_dock.show() - script_code = self.ui.code_editor.toPlainText() + self.script_code = deepcopy(self.ui.code_editor.toPlainText()) # self.shell._sysShell.exec_command(script_code) old_line = '' - for tcl_command_line in script_code.splitlines(): + for tcl_command_line in self.script_code.splitlines(): # do not process lines starting with '#' = comment and empty lines if not tcl_command_line.startswith('#') and tcl_command_line != '': # id FlatCAM is run in Windows then replace all the slashes with @@ -5945,8 +5946,7 @@ class App(QtCore.QObject): self.shell.append_output(result + '\n') old_line = '' - except tk.TclError as e: - log.debug("App.handleRunCode() --> %s" % str(e)) + except tk.TclError: old_line = old_line + tcl_command_line + '\n' except Exception as e: log.debug("App.handleRunCode() --> %s" % str(e)) @@ -7525,7 +7525,7 @@ class App(QtCore.QObject): self.inform.emit('[success] %s...' % _("New Project created")) - def on_file_new(self): + def on_file_new(self, cli=None): """ Callback for menu item File->New. Returns the application to its startup state. This method is thread-safe. @@ -7585,15 +7585,16 @@ class App(QtCore.QObject): # Init Tools self.init_tools() - # Close any Tabs opened in the Plot Tab Area section - for index in range(self.ui.plot_tab_area.count()): - self.ui.plot_tab_area.closeTab(index) - # for whatever reason previous command does not close the last tab so I do it manually - self.ui.plot_tab_area.closeTab(0) + if cli is None: + # Close any Tabs opened in the Plot Tab Area section + for index in range(self.ui.plot_tab_area.count()): + self.ui.plot_tab_area.closeTab(index) + # for whatever reason previous command does not close the last tab so I do it manually + self.ui.plot_tab_area.closeTab(0) - # # And then add again the Plot Area - self.ui.plot_tab_area.addTab(self.ui.plot_tab, "Plot Area") - self.ui.plot_tab_area.protectTab(0) + # # And then add again the Plot Area + self.ui.plot_tab_area.addTab(self.ui.plot_tab, "Plot Area") + self.ui.plot_tab_area.protectTab(0) # take the focus of the Notebook on Project Tab. self.ui.notebook.setCurrentWidget(self.ui.project_tab) diff --git a/README.md b/README.md index 3716270c..cc7e8955 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,10 @@ CAD program, and create G-Code for Isolation routing. ================================================= +16.09.2019 + +- modified the TclCommand New so it will no longer close all tabs when called (it closed the Code Editor tab which may have been holding the code that run) + 15.09.2019 - refactored FlatCAMGeometry.mtool_gen_cncjob() method diff --git a/tclCommands/TclCommandNew.py b/tclCommands/TclCommandNew.py index bf386d0c..3ad7eb76 100644 --- a/tclCommands/TclCommandNew.py +++ b/tclCommands/TclCommandNew.py @@ -36,4 +36,4 @@ class TclCommandNew(TclCommand): :return: None or exception """ - self.app.on_file_new() + self.app.on_file_new(cli=True)