Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions synodic_client/application/screen/tool_update_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,5 +389,3 @@ def _on_package_remove_finished(
tools_view.set_package_removing(plugin_name, package_name, False)
tools_view._updates_checked = False
tools_view.refresh()

self._window.show()
24 changes: 21 additions & 3 deletions tool/pyinstaller/rthook_no_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
When the application is built as a windowed executable (``console=False``),
every ``subprocess.Popen`` call that launches a console program (pip, pipx,
uv, winget, etc.) would briefly flash a visible console window. This hook
merges ``CREATE_NO_WINDOW`` into *creationflags* for every call, suppressing
those flashes while preserving any flags the caller already set.
patches every ``subprocess.Popen`` call with two complementary mitigations:

* ``CREATE_NO_WINDOW`` in *creationflags* — prevents Windows from allocating
a new console for the child process.
* ``STARTUPINFO`` with ``STARTF_USESHOWWINDOW`` and ``wShowWindow=SW_HIDE``
— tells Windows to pass ``SW_HIDE`` as the initial ``nCmdShow`` to the
child, suppressing the brief window flash that some GUI-subsystem tools
(e.g. ``winget.exe``) produce even without a console.

Placed as a runtime hook so the patch is active before any application or
library code spawns subprocesses.
Expand All @@ -15,10 +21,22 @@
from typing import Any

if sys.platform == 'win32':
import subprocess as _sp

_SW_HIDE = 0
_STARTF_USESHOWWINDOW = _sp.STARTF_USESHOWWINDOW
_CREATE_NO_WINDOW = _sp.CREATE_NO_WINDOW

_original_init = subprocess.Popen.__init__

def _patched_init(self: subprocess.Popen, *args: Any, **kwargs: Any) -> None:
kwargs['creationflags'] = kwargs.get('creationflags', 0) | subprocess.CREATE_NO_WINDOW
kwargs['creationflags'] = kwargs.get('creationflags', 0) | _CREATE_NO_WINDOW

startupinfo = kwargs.get('startupinfo') or _sp.STARTUPINFO()
startupinfo.dwFlags |= _STARTF_USESHOWWINDOW
startupinfo.wShowWindow = _SW_HIDE
kwargs['startupinfo'] = startupinfo

_original_init(self, *args, **kwargs)

subprocess.Popen.__init__ = _patched_init