33import threading
44import json
55import keyring
6+ import sys
67import customtkinter
78
89from gui import AVAILABLE_VOICES
@@ -27,6 +28,46 @@ def __init__(self, parent, current_settings, save_callback, close_callback, defa
2728 self .transient (parent )
2829 self .grab_set ()
2930
31+ # Fix pour le bandeau de titre sombre sur Windows
32+ if sys .platform == "win32" :
33+ try :
34+ # Cette méthode force Windows à utiliser un bandeau de titre sombre
35+ # compatible avec le mode sombre de l'application
36+ self .after (10 , lambda : self .wm_attributes ("-alpha" , 0.99 ))
37+ self .after (20 , lambda : self .wm_attributes ("-alpha" , 1.0 ))
38+ # Alternative plus robuste pour Windows 10/11
39+ try :
40+ import ctypes
41+ from ctypes import wintypes
42+
43+ # Constantes Windows pour le mode sombre
44+ DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 = 19
45+ DWMWA_USE_IMMERSIVE_DARK_MODE = 20
46+
47+ # Obtenir le handle de la fenêtre
48+ hwnd = int (self .wm_frame (), 16 )
49+
50+ # Essayer d'abord avec la nouvelle constante (Windows 10 20H1+)
51+ try :
52+ ctypes .windll .dwmapi .DwmSetWindowAttribute (
53+ hwnd ,
54+ DWMWA_USE_IMMERSIVE_DARK_MODE ,
55+ ctypes .byref (ctypes .c_int (1 )),
56+ ctypes .sizeof (ctypes .c_int )
57+ )
58+ except :
59+ # Fallback pour les versions plus anciennes
60+ ctypes .windll .dwmapi .DwmSetWindowAttribute (
61+ hwnd ,
62+ DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 ,
63+ ctypes .byref (ctypes .c_int (1 )),
64+ ctypes .sizeof (ctypes .c_int )
65+ )
66+ except Exception as e :
67+ logging .debug (f"Could not set dark title bar: { e } " )
68+ except Exception as e :
69+ logging .debug (f"Title bar styling failed: { e } " )
70+
3071 self .gemini_api_configured = bool (keyring .get_password ("PodcastGenerator" , "gemini_api_key" ))
3172 self .elevenlabs_api_configured = bool (keyring .get_password ("PodcastGenerator" , "elevenlabs_api_key" ))
3273
@@ -65,6 +106,10 @@ def __init__(self, parent, current_settings, save_callback, close_callback, defa
65106 self .check_voices_update ()
66107
67108 self .update_idletasks ()
109+ # Forcer une largeur minimale sous Windows pour éviter une fenêtre trop étroite à l'ouverture
110+ if sys .platform == "win32" :
111+ self .geometry ("800x600" ) # Définit une taille de départ raisonnable
112+
68113 x = parent .winfo_x () + (parent .winfo_width () - self .winfo_width ()) // 2
69114 y = parent .winfo_y () + (parent .winfo_height () - self .winfo_height ()) // 2
70115 self .geometry (f"+{ x } +{ y } " )
0 commit comments