Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid subprocess window creation with agraph.AGraph._run_prog #514

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chrizzFTD
Copy link

Hi pygraphviz team,

Thanks for this great project!

Context

I'm using pygraphviz through networkx 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 of pygraphviz.agraph.AGraph._run_prog on the subprocess call:

p = subprocess.Popen(
dotargs,
shell=False,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
close_fds=False,
)

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:

A Popen creationflags parameter to specify that a new process will not create a window.

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 through pygraphviz):

Before this PR With this PR
subprocess_window subprocess_no_window

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant