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

Skip to content

Commit b7dfcf4

Browse files
committed
prevent popup windows during execution of latex_to_png_dvipng
1 parent 66aeb3f commit b7dfcf4

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

IPython/lib/latextools.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,13 @@ def latex_to_png_dvipng(s, wrap, color='Black', scale=1.0):
144144
find_cmd('dvipng')
145145
except FindCmdError:
146146
return None
147+
148+
startupinfo = None
149+
if os.name == 'nt':
150+
# prevent popup-windows
151+
startupinfo = subprocess.STARTUPINFO()
152+
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
153+
147154
try:
148155
workdir = Path(tempfile.mkdtemp())
149156
tmpfile = workdir.joinpath("tmp.tex")
@@ -156,7 +163,7 @@ def latex_to_png_dvipng(s, wrap, color='Black', scale=1.0):
156163
with open(os.devnull, 'wb') as devnull:
157164
subprocess.check_call(
158165
["latex", "-halt-on-error", "-interaction", "batchmode", tmpfile],
159-
cwd=workdir, stdout=devnull, stderr=devnull)
166+
cwd=workdir, stdout=devnull, stderr=devnull, startupinfo=startupinfo)
160167

161168
resolution = round(150*scale)
162169
subprocess.check_call(
@@ -179,6 +186,7 @@ def latex_to_png_dvipng(s, wrap, color='Black', scale=1.0):
179186
cwd=workdir,
180187
stdout=devnull,
181188
stderr=devnull,
189+
startupinfo=startupinfo
182190
)
183191

184192
with outfile.open("rb") as f:

0 commit comments

Comments
 (0)