mirror of
https://github.com/netinvent/npbackup.git
synced 2025-09-08 14:05:41 +08:00
GUI: cmd window hide/minimize needs to happen at python level, see #146
This commit is contained in:
parent
467bb95ee5
commit
3a075925ab
3 changed files with 23 additions and 7 deletions
|
@ -7,8 +7,8 @@ __intname__ = "npbackup.compile"
|
|||
__author__ = "Orsiris de Jong"
|
||||
__copyright__ = "Copyright (C) 2023-2024 NetInvent"
|
||||
__license__ = "GPL-3.0-only"
|
||||
__build__ = "2025020401"
|
||||
__version__ = "2.2.1"
|
||||
__build__ = "2025030401"
|
||||
__version__ = "2.2.2"
|
||||
|
||||
|
||||
"""
|
||||
|
@ -303,7 +303,10 @@ def compile(
|
|||
NUITKA_OPTIONS += " --enable-plugin=data-hiding" if have_nuitka_commercial() else ""
|
||||
|
||||
if build_type in ("gui", "viewer"):
|
||||
NUITKA_OPTIONS += " --plugin-enable=tk-inter --windows-console-mode=hide"
|
||||
NUITKA_OPTIONS += " --plugin-enable=tk-inter"
|
||||
# So for an unknown reason, some windows builds will not hide the console, see #146
|
||||
# We replaced this option with a python version in gui\__main__.py
|
||||
# NUITKA_OPTIONS += " --windows-console-mode=hide"
|
||||
else:
|
||||
NUITKA_OPTIONS += " --plugin-disable=tk-inter --nofollow-import-to=FreeSimpleGUI --nofollow-import-to=_tkinter --nofollow-import-to=npbackup.gui"
|
||||
if onefile:
|
||||
|
|
|
@ -51,6 +51,7 @@ from resources.customization import (
|
|||
from npbackup.gui.config import config_gui
|
||||
from npbackup.gui.operations import operations_gui
|
||||
from npbackup.gui.helpers import get_anon_repo_uri, gui_thread_runner
|
||||
from npbackup.gui.handle_window import handle_current_window
|
||||
from npbackup.core.i18n_helper import _t
|
||||
from npbackup.core import upgrade_runner
|
||||
from npbackup.path_helper import CURRENT_DIR
|
||||
|
@ -1236,6 +1237,12 @@ def main_gui(viewer_mode=False):
|
|||
kill_childs, os.getpid(), grace_period=30, process_name=backend_process
|
||||
)
|
||||
try:
|
||||
# Hide CMD window when Nuitka hide action does not work
|
||||
if _DEBUG:
|
||||
handle_current_window(action="minimize")
|
||||
else:
|
||||
handle_current_window(action="minimize")
|
||||
handle_current_window(action="hide")
|
||||
_main_gui(viewer_mode=viewer_mode)
|
||||
sys.exit(logger.get_worst_logger_level())
|
||||
except _tkinter.TclError as exc:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
# This file is part of npbackup
|
||||
|
||||
__intname__ = "npbackup.gui.window_reducer"
|
||||
__intname__ = "npbackup.gui.windows_gui_helper"
|
||||
__author__ = "Orsiris de Jong"
|
||||
__copyright__ = "Copyright (C) 2022-2025 NetInvent"
|
||||
__license__ = "GPL-3.0-only"
|
||||
|
@ -14,9 +14,10 @@ import sys
|
|||
import os
|
||||
|
||||
|
||||
def minimize_current_window():
|
||||
def handle_current_window(action: str = "minimize") -> None:
|
||||
"""
|
||||
Minimizes current commandline window in GUI mode
|
||||
Minimizes / hides current commandline window in GUI mode
|
||||
This helps when Nuitka cmdline hide action does not work
|
||||
"""
|
||||
if os.name == "nt":
|
||||
# pylint: disable=E0401 (import-error)
|
||||
|
@ -29,4 +30,9 @@ def minimize_current_window():
|
|||
# console window will have the name of current executable
|
||||
hwndMain = win32gui.FindWindow(None, current_executable)
|
||||
if hwndMain:
|
||||
win32gui.ShowWindow(hwndMain, win32con.SW_MINIMIZE)
|
||||
if action == "minimize":
|
||||
win32gui.ShowWindow(hwndMain, win32con.SW_MINIMIZE)
|
||||
elif action == "hide":
|
||||
win32gui.ShowWindow(hwndMain, win32con.SW_HIDE)
|
||||
else:
|
||||
raise ValueError(f"Bad action parameter for handling current window: {action}")
|
Loading…
Add table
Reference in a new issue