commit 2e95c94edc465fc2d420e31ecff2b6198acb02a1 Author: Thierry Tallagrand Date: Thu Apr 30 12:50:27 2026 +0200 premier test diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e94ab25 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.venv/ +__pycache__/ +*.pyc + diff --git a/cpu_monitor.py b/cpu_monitor.py new file mode 100644 index 0000000..98cdee5 --- /dev/null +++ b/cpu_monitor.py @@ -0,0 +1,45 @@ +# CPU Monitor - Run with python cpu_monitor_gui.py +# Requirements: psutil (>=5.8.0), tkinter +# Install: pip install psutil tkinter + +import tkinter as tk +import psutil +import time +from datetime import datetime + +# Main window setup +root = tk.Tk() +root.title("CPU Monitor") +root.geometry("400x200") + +# CPU usage label +cpu_label = tk.Label(root, text="CPU Usage: 0%", font=("Arial", 16)) +cpu_label.pack(pady=10) + +# Progress bar for CPU usage +progress_bar = tk.Progressbar(root, orient="horizontal", maximum=100, mode="indeterminate") +progress_bar.pack(pady=10) + +# Time label +time_label = tk.Label(root, text="Time: 00:00:00", font=("Arial", 14)) +time_label.pack(pady=10) + +# Quit button +quit_button = tk.Button(root, text="Quit", command=root.destroy) +quit_button.pack(pady=10) + +# Update GUI every 2 seconds +def update_gui(): + while True: + cpu_percent = psutil.cpu_percent() + current_time = datetime.now().strftime("%H:%M:%S") + cpu_label.config(text=f"CPU Usage: {cpu_percent}%") + progress_bar.config(value=cpu_percent) + time_label.config(text=current_time) + time.sleep(2) + +# Start the update loop +update_gui() + +# Run the Tkinter main loop +root.mainloop() \ No newline at end of file