Repository: spyder-ide/spyder

Issue:
Opening window in a subprocess from Spyder
I asked the question there:
https://stackoverflow.com/questions/55511541/subprocess-in-spyder-matplotlib-and-prints-do-not-work

Running this on a regular console works well, but from Spyder the window does not show up. Prints neither btw.

main.py:

```
import subprocess

subprocess.Popen("test.py", shell=True)

```
test.py:

```
import matplotlib.pyplot as plt

plt.plot([1,3,2])
plt.show()

```
I am using Spyder 3.3.3, python 3.7.3 on windows 10


Discussion:
Thanks for reporting @baudoux! We'll fix this in our next release (3.3.5).
@dalthviz, please work on this one. The idea is to add an option to `Preferences > IPython Console > Advanced Settings`, in a new section called `Windows adjustments`, that allows users to decide if they want to show or not subprocess cmd windows.

Resolving patch:
diff --git a/spyder/config/main.py b/spyder/config/main.py
--- a/spyder/config/main.py
+++ b/spyder/config/main.py
@@ -170,7 +170,11 @@
               'in_prompt': '',
               'out_prompt': '',
               'show_elapsed_time': False,
-              'ask_before_restart': True
+              'ask_before_restart': True,
+              # This is True because there are libraries like Pyomo
+              # that generate a lot of Command Prompts while running,
+              # and that's extremely annoying for Windows users.
+              'hide_cmd_windows': True
               }),
             ('variable_explorer',
              {
diff --git a/spyder/plugins/ipythonconsole.py b/spyder/plugins/ipythonconsole.py
--- a/spyder/plugins/ipythonconsole.py
+++ b/spyder/plugins/ipythonconsole.py
@@ -621,6 +621,16 @@ def setup_page(self):
         prompts_layout.addLayout(prompts_g_layout)
         prompts_group.setLayout(prompts_layout)
 
+        # Windows adjustments
+        windows_group = QGroupBox(_("Windows adjustments"))
+        hide_cmd_windows = newcb(
+            _("Hide command line output windows "
+              "generated by the subprocess module."),
+            'hide_cmd_windows')
+        windows_layout = QVBoxLayout()
+        windows_layout.addWidget(hide_cmd_windows)
+        windows_group.setLayout(windows_layout)
+
         # --- Tabs organization ---
         tabs = QTabWidget()
         tabs.addTab(self.create_tab(interface_group, comp_group,
@@ -629,8 +639,9 @@ def setup_page(self):
                                     _("Graphics"))
         tabs.addTab(self.create_tab(run_lines_group, run_file_group),
                                     _("Startup"))
-        tabs.addTab(self.create_tab(jedi_group, greedy_group, autocall_group, sympy_group,
-                                    prompts_group), _("Advanced Settings"))
+        tabs.addTab(self.create_tab(jedi_group, greedy_group, autocall_group,
+                                    sympy_group, prompts_group,
+                                    windows_group), _("Advanced Settings"))
 
         vlayout = QVBoxLayout()
         vlayout.addWidget(tabs)
diff --git a/spyder/utils/ipython/kernelspec.py b/spyder/utils/ipython/kernelspec.py
--- a/spyder/utils/ipython/kernelspec.py
+++ b/spyder/utils/ipython/kernelspec.py
@@ -117,7 +117,8 @@ def env(self):
             'SPY_JEDI_O': CONF.get('ipython_console', 'jedi_completer'),
             'SPY_SYMPY_O': CONF.get('ipython_console', 'symbolic_math'),
             'SPY_RUN_CYTHON': self.is_cython,
-            'SPY_TESTING': running_under_pytest() or SAFE_MODE
+            'SPY_TESTING': running_under_pytest() or SAFE_MODE,
+            'SPY_HIDE_CMD': CONF.get('ipython_console', 'hide_cmd_windows')
         }
 
         # Add our PYTHONPATH to env_vars


Test patch: