From b7dfcf479203b2423df15b4b0a435dfe3d02efcf 2022-08-04 19:56:50 From: Pieter Eendebak Date: 2022-08-04 19:56:50 Subject: [PATCH] prevent popup windows during execution of latex_to_png_dvipng --- diff --git a/IPython/lib/latextools.py b/IPython/lib/latextools.py index 27aeef5..e832a9e 100644 --- a/IPython/lib/latextools.py +++ b/IPython/lib/latextools.py @@ -144,6 +144,13 @@ def latex_to_png_dvipng(s, wrap, color='Black', scale=1.0): find_cmd('dvipng') except FindCmdError: return None + + startupinfo = None + if os.name == 'nt': + # prevent popup-windows + startupinfo = subprocess.STARTUPINFO() + startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW + try: workdir = Path(tempfile.mkdtemp()) tmpfile = workdir.joinpath("tmp.tex") @@ -156,7 +163,7 @@ def latex_to_png_dvipng(s, wrap, color='Black', scale=1.0): with open(os.devnull, 'wb') as devnull: subprocess.check_call( ["latex", "-halt-on-error", "-interaction", "batchmode", tmpfile], - cwd=workdir, stdout=devnull, stderr=devnull) + cwd=workdir, stdout=devnull, stderr=devnull, startupinfo=startupinfo) resolution = round(150*scale) subprocess.check_call( @@ -179,6 +186,7 @@ def latex_to_png_dvipng(s, wrap, color='Black', scale=1.0): cwd=workdir, stdout=devnull, stderr=devnull, + startupinfo=startupinfo ) with outfile.open("rb") as f: