- fixed Scripts repeating multiple time when the Code Editor is used. This repetition was correlated with multiple openings of the Code Editor window (especially after an error)

- added the autocomplete keywords that can be changed to the defaults dictionary
- 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)
This commit is contained in:
Marius Stanciu 2019-09-16 04:03:19 +03:00 committed by Marius
parent 78b6aa9a83
commit 61120911c6
3 changed files with 19 additions and 14 deletions

View File

@ -2257,6 +2257,7 @@ class App(QtCore.QObject):
# reference for the self.ui.code_editor # reference for the self.ui.code_editor
self.reference_code_editor = None self.reference_code_editor = None
self.script_code = ''
# if Preferences are changed in the Edit -> Preferences tab the value will be set to True # if Preferences are changed in the Edit -> Preferences tab the value will be set to True
self.preferences_changed_flag = False self.preferences_changed_flag = False
@ -5918,11 +5919,11 @@ class App(QtCore.QObject):
if self.ui.shell_dock.isHidden(): if self.ui.shell_dock.isHidden():
self.ui.shell_dock.show() 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) # self.shell._sysShell.exec_command(script_code)
old_line = '' 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 # do not process lines starting with '#' = comment and empty lines
if not tcl_command_line.startswith('#') and tcl_command_line != '': if not tcl_command_line.startswith('#') and tcl_command_line != '':
# id FlatCAM is run in Windows then replace all the slashes with # 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') self.shell.append_output(result + '\n')
old_line = '' old_line = ''
except tk.TclError as e: except tk.TclError:
log.debug("App.handleRunCode() --> %s" % str(e))
old_line = old_line + tcl_command_line + '\n' old_line = old_line + tcl_command_line + '\n'
except Exception as e: except Exception as e:
log.debug("App.handleRunCode() --> %s" % str(e)) log.debug("App.handleRunCode() --> %s" % str(e))
@ -7525,7 +7525,7 @@ class App(QtCore.QObject):
self.inform.emit('[success] %s...' % self.inform.emit('[success] %s...' %
_("New Project created")) _("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 Callback for menu item File->New. Returns the application to its
startup state. This method is thread-safe. startup state. This method is thread-safe.
@ -7585,15 +7585,16 @@ class App(QtCore.QObject):
# Init Tools # Init Tools
self.init_tools() self.init_tools()
# Close any Tabs opened in the Plot Tab Area section if cli is None:
for index in range(self.ui.plot_tab_area.count()): # Close any Tabs opened in the Plot Tab Area section
self.ui.plot_tab_area.closeTab(index) for index in range(self.ui.plot_tab_area.count()):
# for whatever reason previous command does not close the last tab so I do it manually self.ui.plot_tab_area.closeTab(index)
self.ui.plot_tab_area.closeTab(0) # 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 # # And then add again the Plot Area
self.ui.plot_tab_area.addTab(self.ui.plot_tab, "Plot Area") self.ui.plot_tab_area.addTab(self.ui.plot_tab, "Plot Area")
self.ui.plot_tab_area.protectTab(0) self.ui.plot_tab_area.protectTab(0)
# take the focus of the Notebook on Project Tab. # take the focus of the Notebook on Project Tab.
self.ui.notebook.setCurrentWidget(self.ui.project_tab) self.ui.notebook.setCurrentWidget(self.ui.project_tab)

View File

@ -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 15.09.2019
- refactored FlatCAMGeometry.mtool_gen_cncjob() method - refactored FlatCAMGeometry.mtool_gen_cncjob() method

View File

@ -36,4 +36,4 @@ class TclCommandNew(TclCommand):
:return: None or exception :return: None or exception
""" """
self.app.on_file_new() self.app.on_file_new(cli=True)