6

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.

Pavel.D
  • 561
  • 1
  • 15
  • 41
  • 1
    You could have also asked for: __How to run a console application without displaying console window?__ That would be exactly the same question. I suggest to use Stack Overflow search for example with [console application window hidden](https://stackoverflow.com/search?q=console+application+window+hidden). A very common solution is using a VBScript executed with `wscript.exe` (Windows GUI version of Windows Scripting Host) which runs the console application. Also common is using a Python script and `pythonw.exe`, see [pythonw.exe or python.exe?](https://stackoverflow.com/questions/9705982/) – Mofi Jul 08 '19 at 15:01

2 Answers2

2

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)
David Silveiro
  • 1,515
  • 1
  • 15
  • 23
  • Thanks for your explanation and trying to give a possible solution, As you mention changing `silent = True`, wont really help, I do what you suggest but it does't work or help, still latex console displays. maybe some code for forcing `latexmk.bat` may help. – Pavel.D Jul 10 '19 at 09:09
  • 1
    thanks for the reply @Pavel.D I'll have a quick look tomorrow when I have some time :) – David Silveiro Jul 12 '19 at 00:36
0

I believe what you're looking to do is hide the gui that the application uses. It has nothing specific to do with Pylatex.

You could try this

Start-Process "C:\path\to\your.exe" -WindowStyle Hidden

Try this in powershell. If it works for you, you could dump it in a .bat file and use that instead of having to type this in everytime.

  • Thanks for commenting. I have tried Start-Process in PowerShell, but unfortunately does not work. – Pavel.D Nov 24 '19 at 10:51