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

Skip to content

Commit cad8651

Browse files
committed
Merge pull request matplotlib#4041 from dopplershift/anim-windows
BUG : Prevent Windows from opening command prompt
2 parents 6be39e5 + 6301cff commit cad8651

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.'
@@ -251,7 +263,8 @@ def isAvailable(cls):
251263
p = subprocess.Popen(cls.bin_path(),
252264
shell=False,
253265
stdout=subprocess.PIPE,
254-
stderr=subprocess.PIPE)
266+
stderr=subprocess.PIPE,
267+
creationflags=subprocess_creation_flags)
255268
p.communicate()
256269
return True
257270
except OSError:

0 commit comments

Comments
 (0)