From 6723f9496c8642d432c8240df59d1615233de9c0 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Tue, 17 Sep 2019 20:24:34 +0300 Subject: [PATCH] - fixed the --shellvar and --shellfile FlatCAM arguments to work together but the --shellvar has precedence over --shellfile as it is most likely that whatever variable set by --shellvar will be used in the script file run by --shellfile --- FlatCAMApp.py | 70 +++++++++++++++++++++++++++------------------------ README.md | 1 + 2 files changed, 38 insertions(+), 33 deletions(-) diff --git a/FlatCAMApp.py b/FlatCAMApp.py index dccde0c3..910ec373 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -2392,27 +2392,27 @@ class App(QtCore.QObject): # ############################################################################### App.log.debug("END of constructor. Releasing control.") + # ##################################################################################### + # ########################## SHOW GUI ################################################# + # ##################################################################################### + + # finish the splash + self.splash.finish(self.ui) + + settings = QSettings("Open Source", "FlatCAM") + if settings.contains("maximized_gui"): + maximized_ui = settings.value('maximized_gui', type=bool) + if maximized_ui is True: + self.ui.showMaximized() + else: + self.ui.show() + # ##################################################################################### # ########################## START-UP ARGUMENTS ####################################### # ##################################################################################### # test if the program was started with a script as parameter - if self.cmd_line_shellfile: - try: - with open(self.cmd_line_shellfile, "r") as myfile: - if show_splash: - self.splash.showMessage('%s: %ssec\n%s' % ( - _("Canvas initialization started.\n" - "Canvas initialization finished in"), '%.2f' % self.used_time, - _("Executing Tcl Script ...")), - alignment=Qt.AlignBottom | Qt.AlignLeft, - color=QtGui.QColor("gray")) - cmd_line_shellfile_text = myfile.read() - self.shell._sysShell.exec_command(cmd_line_shellfile_text) - except Exception as ext: - print("ERROR: ", ext) - sys.exit(2) - elif self.cmd_line_shellvar: + if self.cmd_line_shellvar: try: cnt = 0 command_tcl = 0 @@ -2434,26 +2434,30 @@ class App(QtCore.QObject): print("ERROR: ", ext) sys.exit(2) - # accept some type file as command line parameter: FlatCAM project, FlatCAM preferences or scripts - # the path/file_name must be enclosed in quotes if it contain spaces + if self.cmd_line_shellfile: + try: + if self.ui.shell_dock.isHidden(): + self.ui.shell_dock.show() + + with open(self.cmd_line_shellfile, "r") as myfile: + if show_splash: + self.splash.showMessage('%s: %ssec\n%s' % ( + _("Canvas initialization started.\n" + "Canvas initialization finished in"), '%.2f' % self.used_time, + _("Executing Tcl Script ...")), + alignment=Qt.AlignBottom | Qt.AlignLeft, + color=QtGui.QColor("gray")) + cmd_line_shellfile_text = myfile.read() + self.shell._sysShell.exec_command(cmd_line_shellfile_text) + except Exception as ext: + print("ERROR: ", ext) + sys.exit(2) + + # accept some type file as command line parameter: FlatCAM project, FlatCAM preferences or scripts + # the path/file_name must be enclosed in quotes if it contain spaces if App.args: self.args_at_startup.emit(App.args) - # finish the splash - self.splash.finish(self.ui) - - # ##################################################################################### - # ########################## SHOW GUI ################################################# - # ##################################################################################### - - settings = QSettings("Open Source", "FlatCAM") - if settings.contains("maximized_gui"): - maximized_ui = settings.value('maximized_gui', type=bool) - if maximized_ui is True: - self.ui.showMaximized() - else: - self.ui.show() - @staticmethod def copy_and_overwrite(from_path, to_path): """ diff --git a/README.md b/README.md index 3b14f54a..238ca32c 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ CAD program, and create G-Code for Isolation routing. - added a new command line parameter for FlatCAM named '--shellvars' which can load a text file with variables for Tcl Shell in the format: one variable assignment per line and looking like: 'a=3' without quotes - made --shellvars into --shellvar and make it only one list of commands passed to the Tcl. The list is separated by comma but without spaces. The variables are accessed in Tcl with the names shellvar_x where x is the index in the list of command comma separated values - fixed an issue in the TclShell that generated an exception IndexError which crashed the software +- fixed the --shellvar and --shellfile FlatCAM arguments to work together but the --shellvar has precedence over --shellfile as it is most likely that whatever variable set by --shellvar will be used in the script file run by --shellfile 16.09.2019