Monitor All System Information Using a Desktop App with a Modern GUI UI in Python (PYQT, PYSIDE2/6, PSUTIL)

Posted by


In this tutorial, we will create a desktop app using Python, PYQT, PySide2/6, and PSUtil to monitor all system information. This application will display various system information such as CPU usage, memory usage, disk usage, network activity, and more in a modern GUI interface.

Here is a step-by-step guide on how to create this desktop app:

Step 1: Install the necessary libraries
First, we need to install the required libraries for our application. Open a command prompt or terminal and run the following commands:

pip install pyqt5
pip install pyside2
pip install psutil

Step 2: Create a new Python file for the desktop app
Next, create a new Python file for the desktop app. You can name the file anything you like, for example, system_monitor.py.

Step 3: Import the necessary libraries
In the Python file, import the necessary libraries like PyQt5, PySide2/6, and PSUtil:

from PyQt5.QtWidgets import QMainWindow, QApplication, QGridLayout, QWidget, QLabel
from PyQt5.QtCore import QTimer
import psutil

Step 4: Create the main window class
Create a class for the main window of the app that will inherit from QMainWindow:

class SystemMonitorApp(QMainWindow):
    def __init__(self):
        super().__init__()

        self.setWindowTitle("System Monitor")
        self.setGeometry(100, 100, 800, 600)

        self.central_widget = QWidget()
        self.setCentralWidget(self.central_widget)

        self.layout = QGridLayout()
        self.centralWidget().setLayout(self.layout)

        self.timer = QTimer()
        self.timer.timeout.connect(self.update_system_info)
        self.timer.start(1000)  # Update every 1 second

        self.init_gui()

Step 5: Create a method to initialize the GUI
Create a method called init_gui that will initialize the GUI elements like labels to display system information:

def init_gui(self):
    self.cpu_label = QLabel()
    self.layout.addWidget(self.cpu_label, 0, 0)

    self.memory_label = QLabel()
    self.layout.addWidget(self.memory_label, 1, 0)

    self.disk_label = QLabel()
    self.layout.addWidget(self.disk_label, 2, 0)

    self.network_label = QLabel()
    self.layout.addWidget(self.network_label, 3, 0)

    self.update_system_info()

Step 6: Create a method to update system information
Create a method called update_system_info that will update the system information displayed in the labels:

def update_system_info(self):
    cpu_percent = psutil.cpu_percent(interval=0)
    self.cpu_label.setText(f"CPU Usage: {cpu_percent}%")

    memory = psutil.virtual_memory()
    self.memory_label.setText(f"Memory Usage: {memory.percent}%")

    disk = psutil.disk_usage("/")
    self.disk_label.setText(f"Disk Usage: {disk.percent}%")

    network = psutil.net_io_counters()
    self.network_label.setText(f"Network Activity: {network.bytes_sent} bytes sent, {network.bytes_recv} bytes received")

Step 7: Run the application
Finally, create an instance of the SystemMonitorApp class and run the application:

if __name__ == "__main__":
    app = QApplication([])
    system_monitor_app = SystemMonitorApp()
    system_monitor_app.show()
    app.exec_()

Congratulations! You have successfully created a desktop app using Python, PYQT, PySide2/6, and PSUtil to monitor all system information. You can further customize the GUI and add more system information to display as per your requirements.

0 0 votes
Article Rating

Leave a Reply

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
@bhargavkumar5853
6 hours ago

When will this source code be made available to everyone?

@haunguyenfreelancer
6 hours ago

I need name music, thanks 😂

2
0
Would love your thoughts, please comment.x
()
x