Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide command prompt popup during launching PyLatex or Latexmk

How could I hide command prompt that pops up during launch and execute pylatex codes. I have a page working on it and generate pdf. I need to hide popup window when I run the code.

Talking about this window:

enter image description here

Is there a way to hide or not showing latexmk.exe popup?

I have been googling and searching but I found nothing related to the issue.

like image 940
Pavel.D Avatar asked Jul 03 '19 21:07

Pavel.D


1 Answers

Having had a look into Pylatex's source, the generate_pdf() method which I'm guessing you could be using, does in-fact allow for a silent=true/false parameter

Source comment:

silent: bool
    Whether to hide compiler output

However, this doesn't seem to be doing an awful lot and I believe if you were to pass that parameter in, you might still face the same issue, due to;

    else:
        if not silent:
            print(output.decode())

It seems there are two individual places where the use of check_output, which is a subprocess method, is being called to start-up latexmk. Which contributes to the window your seeing.

pylatest/document.py lines:

  • 227

        output = subprocess.check_output(command,
                                         stderr=subprocess.STDOUT)
    
  • 248

         output = subprocess.check_output(command,
                                         stderr=subprocess.STDOUT)
    

Possible Solution

You could make the adjustment to both those lines, by passing in the extra parameter shell=True, which will not display a cmd window upon invoking latexmk.

         output = subprocess.check_output(command,
                                         stderr=subprocess.STDOUT,
                                         shell=True)
like image 164
David S Avatar answered Sep 29 '22 17:09

David S