Avoid subprocess window creation with agraph.AGraph._run_prog #514
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi pygraphviz team,
Thanks for this great project!
Context
I'm using
pygraphviz
throughnetworkx
for some python widgets that are added to a host application in the form of a plugin.In Windows OS, running
networkx.drawing.pygraphviz_layout
leads to a terminal window appearing and disappearing very quickly. This seems to happen exactly during execution ofpygraphviz.agraph.AGraph._run_prog
on the subprocess call:pygraphviz/pygraphviz/agraph.py
Lines 1381 to 1388 in fce4667
Changes in this PR
This PR proposes that if
subprocess.CREATE_NO_WINDOW
is available (Python-3.7+ & Windows OS), then it will be passed as a creation flag to the subprocess. The python docs state this flag is for:An example with this change with the python widgets I'm using (the top left selection triggers the
networkx
call, and on the bottom section we see the graph GUI that has been created throughpygraphviz
):I aimed at making the changes not invasive, though I'd be happy to make adjustments that you see fit; please let me know your thoughts,
Thanks!
-Chris