diff --git a/Code_objets/__pycache__/Display.cpython-310.pyc b/Code_objets/__pycache__/Display.cpython-310.pyc index b2170e9591314447e8a13d70e170b9cae774f34b..ce8f04f19664a039fe127ec94b25b6607f4ace33 100644 Binary files a/Code_objets/__pycache__/Display.cpython-310.pyc and b/Code_objets/__pycache__/Display.cpython-310.pyc differ diff --git a/Code_objets/__pycache__/ImageProcessing.cpython-310.pyc b/Code_objets/__pycache__/ImageProcessing.cpython-310.pyc index 08735fde6bd45504c90013cab1f8dcb071789803..c99760e2bcecd0066e7f4f9d7b9ae4529e83bce2 100644 Binary files a/Code_objets/__pycache__/ImageProcessing.cpython-310.pyc and b/Code_objets/__pycache__/ImageProcessing.cpython-310.pyc differ diff --git a/Code_objets/__pycache__/Main.cpython-310.pyc b/Code_objets/__pycache__/Main.cpython-310.pyc index 68af849b8fc70a0c48ed4b41d9d702408da65197..a0b1bc93be8307a1b2f8d23e2810a75c30885253 100644 Binary files a/Code_objets/__pycache__/Main.cpython-310.pyc and b/Code_objets/__pycache__/Main.cpython-310.pyc differ diff --git a/Code_objets/__pycache__/Menu.cpython-310.pyc b/Code_objets/__pycache__/Menu.cpython-310.pyc index d58ad8dfad2736a4aa7de1d20331852235f347a7..ce9d7b57e75225fab452216fc37fa6b650f79b01 100644 Binary files a/Code_objets/__pycache__/Menu.cpython-310.pyc and b/Code_objets/__pycache__/Menu.cpython-310.pyc differ diff --git a/Code_objets/__pycache__/Parameters.cpython-310.pyc b/Code_objets/__pycache__/Parameters.cpython-310.pyc index a1fef98059f7080b27dd78b68da050f302d94867..b0b5de2665bbbec468cb0efca8cf3ece29f80928 100644 Binary files a/Code_objets/__pycache__/Parameters.cpython-310.pyc and b/Code_objets/__pycache__/Parameters.cpython-310.pyc differ diff --git a/Code_objets/__pycache__/Point.cpython-310.pyc b/Code_objets/__pycache__/Point.cpython-310.pyc index 9439b4b96538d8fb0358552264e1412cc94e2503..8bddbd546715215a73f05cd2f67bd9f319f53228 100644 Binary files a/Code_objets/__pycache__/Point.cpython-310.pyc and b/Code_objets/__pycache__/Point.cpython-310.pyc differ diff --git a/Code_objets/__pycache__/Trajectory.cpython-310.pyc b/Code_objets/__pycache__/Trajectory.cpython-310.pyc index 074bc8f3824d01f6628aa6e2931e66119f1012d4..6e420dad93b877411490387262f423ac887e6b80 100644 Binary files a/Code_objets/__pycache__/Trajectory.cpython-310.pyc and b/Code_objets/__pycache__/Trajectory.cpython-310.pyc differ diff --git a/Code_objets/__pycache__/UI.cpython-310.pyc b/Code_objets/__pycache__/UI.cpython-310.pyc index d24001918bbdac43b390957180891882d316a121..d26ef227592781f64a23482cc23af63b687e5f37 100644 Binary files a/Code_objets/__pycache__/UI.cpython-310.pyc and b/Code_objets/__pycache__/UI.cpython-310.pyc differ diff --git a/Code_objets/__pycache__/VideoManager.cpython-310.pyc b/Code_objets/__pycache__/VideoManager.cpython-310.pyc index 96cd74133fa8fe645feb42105a8e077505bfff2f..5d76ee88c89b7894e9d867b2fa10899bd4c1b2e7 100644 Binary files a/Code_objets/__pycache__/VideoManager.cpython-310.pyc and b/Code_objets/__pycache__/VideoManager.cpython-310.pyc differ diff --git a/test_chargement.py b/test_chargement.py index c8908f807ce64f211255ad6af876089c5a8cc93b..3283d09869ec1fb332801927d1c906aa4f18eb7f 100644 --- a/test_chargement.py +++ b/test_chargement.py @@ -43,7 +43,7 @@ def charger_menu(): print(f"Temps d'exécution : {-(temps - tmp):.6f} secondes") a.mainloop() # Lancer l'application principale - a.destroy() + # --- Lancer le chargement en arrière-plan --- thread = threading.Thread(target=charger_menu) diff --git a/test_chercherdossier.py b/test_chercherdossier.py index b38b9876adbd58be61ca6ca1d6d20b0e8377cddb..4b59e22711c326131b318c0f21a1f25c1bf584a0 100644 --- a/test_chercherdossier.py +++ b/test_chercherdossier.py @@ -1,11 +1,39 @@ import os import sys +import time +import threading +import os +import sys +from tkinter import Tk, Label +from PIL import Image, ImageTk # Installer Pillow si nécessaire : pip install pillow + +# --- Création du Splash Screen --- +splash = Tk() +splash.overrideredirect(True) # Enlever la barre de titre + +# Charger l'image +image = Image.open("LogoSymbole_canard.png") +photo = ImageTk.PhotoImage(image) + +# Définir la taille et centrer +screen_width = splash.winfo_screenwidth() +screen_height = splash.winfo_screenheight() +img_width, img_height = image.size +x_pos = (screen_width - img_width) // 2 +y_pos = (screen_height - img_height) // 2 +splash.geometry(f"{img_width}x{img_height}+{x_pos}+{y_pos}") + +# Afficher l'image +label = Label(splash, image=photo) +label.pack() +splash.update() # Mise à jour de l'affichage base_dir = os.path.dirname(os.path.abspath(__file__)) -dossier_path = os.path.join(base_dir,'Code_objets') +dossier_path = os.path.join(base_dir,'Objet') sys.path.append(dossier_path) -import Menu -a = Menu.App() +import menu +a = menu.App() +splash.destroy() a.mainloop() diff --git a/test_multithrading_logo.py b/test_multithrading_logo.py index 57a1d5a06b8925cd523c943bd79d64bc3ecae4f9..6d58413ba07346e1310d55f1fb762aaff96aa435 100644 --- a/test_multithrading_logo.py +++ b/test_multithrading_logo.py @@ -3,20 +3,17 @@ from PIL import Image, ImageTk import threading import time - - -# Fonction pour afficher le splash screen def show_splash(): - global splash # Garder une référence à la fenêtre + global splash, photo splash = tk.Tk() - splash.overrideredirect(True) # Enlever la barre de titre + splash.overrideredirect(True) # Charger l'image - image = Image.open("LogoSymbole_canard.png") # Remplace par ton logo + image = Image.open("LogoSymbole_canard.png") photo = ImageTk.PhotoImage(image) - # Définir la taille et centrer + # Centrer la fenêtre screen_width = splash.winfo_screenwidth() screen_height = splash.winfo_screenheight() img_width, img_height = image.size @@ -24,40 +21,41 @@ def show_splash(): y_pos = (screen_height - img_height) // 2 splash.geometry(f"{img_width}x{img_height}+{x_pos}+{y_pos}") - # Afficher l'image label = tk.Label(splash, image=photo) + label.image = photo # Évite la suppression de l'image par le garbage collector label.pack() - splash.update() - splash.mainloop() # Garde la fenêtre active jusqu'à ce qu'on la ferme + # Lancer le thread du programme principal + global main_thread + main_thread = threading.Thread(target=load_main_program, daemon=True) + main_thread.start() -# Fonction pour charger le programme principal -def load_main_program(): - time.sleep(3) # Simule un chargement + # Vérifier périodiquement si le programme principal est chargé + splash.after(100, check_thread) - # Fermer l'écran de chargement - splash.destroy() + splash.mainloop() +def load_main_program(): + """Charge le programme principal (menu.App), sans interaction directe avec Tkinter.""" import os - import sys + import sys + base_dir = os.path.dirname(os.path.abspath(__file__)) - - dossier_path = os.path.join(base_dir,'Objet') + dossier_path = os.path.join(base_dir, 'Objet') sys.path.append(dossier_path) - import menu + global app + app = menu.App() # Instanciation de l'application +def check_thread(): + """Vérifie si le thread principal a fini de charger le programme.""" + if not main_thread.is_alive(): + splash.destroy() # Fermer le splash + app.mainloop() # Lancer l'application principale dans le thread principal + else: + splash.after(100, check_thread) # Vérifier à nouveau après 100 ms - # Lancer le programme principal ici - a = menu.App() - a.mainloop() - -# Démarrer le splash screen dans un thread -splash_thread = threading.Thread(target=show_splash) -splash_thread.start() - -# Charger le programme principal dans un autre thread -main_thread = threading.Thread(target=load_main_program) -main_thread.start() +# Démarrer le splash screen dans le thread principal +show_splash()