From a5616622a3e4ac6b4b44d57c3b2c150f33476255 Mon Sep 17 00:00:00 2001 From: Ladebeze66 Date: Wed, 5 Mar 2025 16:39:37 +0100 Subject: [PATCH] modifschool --- main.py | 4 ++-- requirements.txt | 3 +-- src/gui.py | 45 +++++++++++---------------------------------- 3 files changed, 14 insertions(+), 38 deletions(-) diff --git a/main.py b/main.py index a8f5ae1..43f9683 100644 --- a/main.py +++ b/main.py @@ -5,7 +5,7 @@ import os sys.path.append(os.path.abspath("src")) from src.training_model import train_model -from src.gui import show_gui # Import propre et structuré +from src.gui import cli_interface # Nouvelle importation def main(): print("Bienvenue dans le modèle de prédiction de prix de voiture !") @@ -17,7 +17,7 @@ def main(): from src.prediction import predict_price # Lancer l'interface graphique après l'entraînement print("Lancement de l'interface graphique...") - show_gui(predict_price) + cli_interface(predict_price) if __name__ == "__main__": main() diff --git a/requirements.txt b/requirements.txt index 03db77d..5c821e5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,4 @@ numpy pandas matplotlib -seaborn -tk \ No newline at end of file +seaborn \ No newline at end of file diff --git a/src/gui.py b/src/gui.py index 1f2d34f..8c1ee6d 100644 --- a/src/gui.py +++ b/src/gui.py @@ -1,36 +1,13 @@ -import tkinter as tk -from tkinter import messagebox - -def show_gui(predict_price): - """Affiche l'interface graphique Tkinter pour entrer un kilométrage et voir le prix estimé.""" - - def estimate_price(): +def cli_interface(predict_price): + """Interface en ligne de commande pour entrer un kilométrage et voir le prix estimé.""" + while True: + user_input = input("Entrez un kilométrage (ou 'q' pour quitter) : ") + if user_input.lower() == 'q': + print("Fermeture du programme.") + break try: - km = float(entry_km.get()) # Récupère la valeur entrée - price = predict_price(km) # Prédiction du prix - label_result.config(text=f"Prix estimé : {price:.2f} €", fg="green") # Affiche le prix + km = float(user_input) + price = predict_price(km) + print(f"Prix estimé : {price:.2f} €") except ValueError: - messagebox.showerror("Erreur", "Veuillez entrer un kilométrage valide.") - - root = tk.Tk() - root.title("Estimation de prix de voiture") - - frame = tk.Frame(root, padx=20, pady=20) - frame.pack() - - label_title = tk.Label(frame, text="Estimation de prix de voiture", font=("Arial", 14, "bold")) - label_title.pack() - - label_km = tk.Label(frame, text="Entrez le kilométrage :") - label_km.pack() - - entry_km = tk.Entry(frame) - entry_km.pack() - - btn_estimate = tk.Button(frame, text="Estimer le prix", command=estimate_price) - btn_estimate.pack() - - label_result = tk.Label(frame, text="", font=("Arial", 12)) - label_result.pack() - - root.mainloop() + print("Erreur : Veuillez entrer un kilométrage valide.")