Show More
@@ -0,0 +1,5 b'' | |||||
|
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 |
@@ -144,6 +144,13 b" def latex_to_png_dvipng(s, wrap, color='Black', scale=1.0):" | |||||
144 | find_cmd('dvipng') |
|
144 | find_cmd('dvipng') | |
145 | except FindCmdError: |
|
145 | except FindCmdError: | |
146 | return None |
|
146 | 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 | ||||
147 | try: |
|
154 | try: | |
148 | workdir = Path(tempfile.mkdtemp()) |
|
155 | workdir = Path(tempfile.mkdtemp()) | |
149 | tmpfile = "tmp.tex" |
|
156 | tmpfile = "tmp.tex" | |
@@ -156,7 +163,11 b" def latex_to_png_dvipng(s, wrap, color='Black', scale=1.0):" | |||||
156 | with open(os.devnull, 'wb') as devnull: |
|
163 | with open(os.devnull, 'wb') as devnull: | |
157 | subprocess.check_call( |
|
164 | subprocess.check_call( | |
158 | ["latex", "-halt-on-error", "-interaction", "batchmode", tmpfile], |
|
165 | ["latex", "-halt-on-error", "-interaction", "batchmode", tmpfile], | |
159 |
cwd=workdir, |
|
166 | cwd=workdir, | |
|
167 | stdout=devnull, | |||
|
168 | stderr=devnull, | |||
|
169 | startupinfo=startupinfo, | |||
|
170 | ) | |||
160 |
|
171 | |||
161 | resolution = round(150*scale) |
|
172 | resolution = round(150*scale) | |
162 | subprocess.check_call( |
|
173 | subprocess.check_call( | |
@@ -179,6 +190,7 b" def latex_to_png_dvipng(s, wrap, color='Black', scale=1.0):" | |||||
179 | cwd=workdir, |
|
190 | cwd=workdir, | |
180 | stdout=devnull, |
|
191 | stdout=devnull, | |
181 | stderr=devnull, |
|
192 | stderr=devnull, | |
|
193 | startupinfo=startupinfo, | |||
182 | ) |
|
194 | ) | |
183 |
|
195 | |||
184 | with workdir.joinpath(outfile).open("rb") as f: |
|
196 | with workdir.joinpath(outfile).open("rb") as f: |
General Comments 0
You need to be logged in to leave comments.
Login now