π½ Disk Space Analyzer GUI App in Python – FuzzuTech | Analyze Your Drives with Live Pie Charts!
Demo :
Click Video πππ
Code :
import customtkinter as ctk
import matplotlib.pyplot as plt
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
import psutil
import shutil
# Appearance
ctk.set_appearance_mode("System")
ctk.set_default_color_theme("blue")
# GUI
app = ctk.CTk()
app.title("Disk Space Analyzer - FuzzuTech")
app.geometry("600x500")
app.resizable(False, False)
# Title
title = ctk.CTkLabel(app, text="πΎ Disk Space Analyzer", font=("Arial Black", 22))
title.pack(pady=20)
# Frame for pie chart
frame = ctk.CTkFrame(app, width=600, height=400)
frame.pack(pady=10)
# Pie chart generation
def show_pie_chart():
for widget in frame.winfo_children():
widget.destroy()
partitions = psutil.disk_partitions()
labels, sizes = [], []
for part in partitions:
try:
usage = shutil.disk_usage(part.mountpoint)
total_gb = usage.total / (1024 ** 3)
labels.append(part.device)
sizes.append(total_gb)
except:
continue
if not labels:
labels = ["No partitions"]
sizes = [1]
fig, ax = plt.subplots(figsize=(5, 4), dpi=100)
ax.pie(sizes, labels=labels, autopct='%1.1f%%', startangle=140)
ax.axis('equal')
chart = FigureCanvasTkAgg(fig, master=frame)
chart.draw()
chart.get_tk_widget().pack()
# Button
btn = ctk.CTkButton(app, text="π Analyze Now", command=show_pie_chart)
btn.pack(pady=10)
# Initial Display
show_pie_chart()
# Run
app.mainloop()
Comments
Post a Comment