Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 36a7a21

Browse files
committed
Merge pull request #4041 from dopplershift/anim-windows
BUG : Prevent Windows from opening command prompt
1 parent 4ed6cf3 commit 36a7a21

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/matplotlib/animation.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import six
2424
from six.moves import xrange, zip
2525

26+
import platform
2627
import sys
2728
import itertools
2829
import contextlib
@@ -31,6 +32,16 @@
3132
from matplotlib import verbose
3233
from matplotlib import rcParams
3334

35+
# Process creation flag for subprocess to prevent it raising a terminal
36+
# window. See for example:
37+
# https://stackoverflow.com/questions/24130623/using-python-subprocess-popen-cant-prevent-exe-stopped-working-prompt
38+
if platform.system() == 'Windows':
39+
CREATE_NO_WINDOW = 0x08000000
40+
subprocess_creation_flags = CREATE_NO_WINDOW
41+
else:
42+
# Apparently None won't work here
43+
subprocess_creation_flags = 0
44+
3445
# Other potential writing methods:
3546
# * http://pymedia.org/
3647
# * libmng (produces swf) python wrappers: https://github.com/libming/libming
@@ -189,7 +200,8 @@ def _run(self):
189200
' '.join(command))
190201
self._proc = subprocess.Popen(command, shell=False,
191202
stdout=output, stderr=output,
192-
stdin=subprocess.PIPE)
203+
stdin=subprocess.PIPE,
204+
creationflags=subprocess_creation_flags)
193205

194206
def finish(self):
195207
'Finish any processing for writing the movie.'
@@ -250,7 +262,8 @@ def isAvailable(cls):
250262
p = subprocess.Popen(cls.bin_path(),
251263
shell=False,
252264
stdout=subprocess.PIPE,
253-
stderr=subprocess.PIPE)
265+
stderr=subprocess.PIPE,
266+
creationflags=subprocess_creation_flags)
254267
p.communicate()
255268
return True
256269
except OSError:

0 commit comments

Comments
 (0)