Просмотр исходного кода

- 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

Marius Stanciu 6 лет назад
Родитель
Сommit
6723f9496c
2 измененных файлов с 38 добавлено и 33 удалено
  1. 37 33
      FlatCAMApp.py
  2. 1 0
      README.md

+ 37 - 33
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,25 +2434,29 @@ 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 App.args:
-            self.args_at_startup.emit(App.args)
-
-        # finish the splash
-        self.splash.finish(self.ui)
+        if self.cmd_line_shellfile:
+            try:
+                if self.ui.shell_dock.isHidden():
+                    self.ui.shell_dock.show()
 
-        # #####################################################################################
-        # ########################## SHOW GUI #################################################
-        # #####################################################################################
+                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)
 
-        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()
+            # 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)
 
     @staticmethod
     def copy_and_overwrite(from_path, to_path):

+ 1 - 0
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