In Real time: With interface to watch the CPU / RAM

In Real time: With interface to watch the CPU / RAM

You want to watch the CPU / RAM usage in real time? You can do it with this script

You need only to install tkinter. pip install tkinter.

Then open an editor or your IDE and then you can copy this script.

The interface of tkinter

tkinter interface in Python for Linux

The script

import tkinter as tk, psutil

root = tk.Tk()
root.title("CPU & RAM Monitor")
root.geometry("600x300")
root.configure(bg="black")

lbl = tk.Label(root, font=("Arial",30,"bold"),bg="black",fg="lime")
lbl.pack(expand=True)

def update():
    cpu = psutil.cpu_percent()
    ram = psutil.virtual_memory().percent
    lbl.config(text=f"CPU Usage: {cpu}%\n RAM Usage: {ram}%")
    root.after(1000, update)
update()
root.mainloop()

More Python on my blog?

Die Kommentare sind geschlossen.