Skip to content

Avoid the packaged application flashing black cmdline window. #2225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 11, 2023

Conversation

BruceLee569
Copy link
Contributor

import xlwings as xw

Package an exe application through pyinstaller -w main.py , main.py with the above code, because the subprocess tasklist command is called, a black cmdline window will flash every time when the program exits.

```python
import xlwings as xw
```

Package an exe application through `pyinstaller -w main.py` ,  main.py with the above code,  because the subprocess `tasklist` command is called, a black cmdline window will flash every time when the program exits.
@fzumstein
Copy link
Member

I'd like to avoid introducing shell=True, see https://stackoverflow.com/a/3172488/918626
Is there no way to suppress this with a pyinstaller setting? Otherwise, I might think about removing the atexit handler again so it won't get called automatically upon exit of the program. Not sure if leaving it in the App.quit() and App.kill() would still cause this issue?

…process on windows.

Avoid introducing shell=True, see https://stackoverflow.com/a/3172488/918626, and we can use `creationflags` to avoid cmdline window flash, see https://stackoverflow.com/a/2935727/11687405
@BruceLee569
Copy link
Contributor Author

After a brief search, we can use creationflags to avoid cmdline window flash, see https://stackoverflow.com/a/2935727/11687405.

Now we just need to change shell=True to creationflags=0x08000000, or creationflags = subprocess.CREATE_NO_WINDOW from Python 3.7.

@fzumstein
Copy link
Member

great! As xlwings doesn't support < 3.7, I'd prefer to use subprocess.CREATE_NO_WINDOW though

…plicit

Refer to https://docs.python.org/3/library/subprocess.html?highlight=create_no_window#subprocess.CREATE_NO_WINDOW, ss xlwings doesn't support < 3.7, use `subprocess.CREATE_NO_WINDOW` to replace `0x08000000`, which make the code more explicit.
@BruceLee569
Copy link
Contributor Author

I'm not familiar with the operation of git. I just committed the branch code. Now, could I just apply for approval and merge into the main branch?

@fzumstein fzumstein added this to the 0.30.5 milestone Apr 11, 2023
@fzumstein fzumstein merged commit a38beda into xlwings:main Apr 11, 2023
@fzumstein
Copy link
Member

Thanks! This is now merged and will be released with 0.30.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants