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

Skip to content

Commit c24bf50

Browse files
authored
Merge pull request #13679 from eendebakpt/prevent_popup_windows
Prevent popup windows during execution of latex_to_png_dvipng
2 parents 2f93f50 + d2256dd commit c24bf50

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

IPython/lib/latextools.py

Lines changed: 13 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 = "tmp.tex"
@@ -156,7 +163,11 @@ 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,
167+
stdout=devnull,
168+
stderr=devnull,
169+
startupinfo=startupinfo,
170+
)
160171

161172
resolution = round(150*scale)
162173
subprocess.check_call(
@@ -179,6 +190,7 @@ def latex_to_png_dvipng(s, wrap, color='Black', scale=1.0):
179190
cwd=workdir,
180191
stdout=devnull,
181192
stderr=devnull,
193+
startupinfo=startupinfo,
182194
)
183195

184196
with workdir.joinpath(outfile).open("rb") as f:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
No popup in window for latex generation
2+
=======================================
3+
4+
When generating latex (e.g. via `_latex_repr_`) no popup window is shows under Windows.
5+

0 commit comments

Comments
 (0)