Refactor windowed mode and subprocess handling

Removed redundant windowed mode setup from main.py and simplified subprocess creation flags logic across core and GUI modules. Centralized subprocess creation flags usage, eliminated custom run_subprocess_hidden wrapper, and improved logging handler setup for better compatibility with windowed applications.
This commit is contained in:
Your Name
2025-08-27 23:00:08 +03:00
parent b23be4335e
commit f390d23f54
5 changed files with 35 additions and 169 deletions
-46
View File
@@ -1,50 +1,4 @@
import sys
import os
# Early detection and handling of windowed mode to prevent console window flicker
def setup_windowed_mode():
"""
Setup windowed mode handling to prevent console window flickering.
This must be called as early as possible in the application startup.
"""
if getattr(sys, 'frozen', False):
# Running as compiled executable (PyInstaller)
if sys.stdout is None or sys.stderr is None:
# Windowed mode - completely suppress console output
import io
null_stream = io.StringIO()
if sys.stdout is None:
sys.stdout = null_stream
if sys.stderr is None:
sys.stderr = null_stream
else:
# Console mode but compiled - redirect to null to prevent window flicker
if os.name == 'nt': # Windows
try:
import io
# Create a null output stream
null_stream = io.StringIO()
# Only redirect if we detect this might cause console window issues
# Check if we're not already in a console
try:
# Try to get console window handle - if this fails, we're likely windowed
import ctypes
kernel32 = ctypes.windll.kernel32
console_window = kernel32.GetConsoleWindow()
if console_window == 0:
# No console window exists, redirect to prevent one from appearing
sys.stdout = null_stream
sys.stderr = null_stream
except:
# If console detection fails, err on the side of caution
sys.stdout = null_stream
sys.stderr = null_stream
except:
# If all else fails, continue normally
pass
# Call windowed mode setup immediately
setup_windowed_mode()
from PySide6.QtWidgets import QApplication, QMessageBox