电脑信息-cpu
This commit is contained in:
commit
a45a161427
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# 默认忽略的文件
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# 基于编辑器的 HTTP 客户端请求
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
10
.idea/PC_Monitor.iml
generated
Normal file
10
.idea/PC_Monitor.iml
generated
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="jdk" jdkName="Python 3.11 (PC_Monitor)" jdkType="Python SDK" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/PC_Monitor.iml" filepath="$PROJECT_DIR$/.idea/PC_Monitor.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
208
PC_Monitor.py
Normal file
208
PC_Monitor.py
Normal file
@ -0,0 +1,208 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
## Form generated from reading UI file 'PC_Monitor.ui'
|
||||||
|
##
|
||||||
|
## Created by: Qt User Interface Compiler version 6.9.0
|
||||||
|
##
|
||||||
|
## WARNING! All changes made in this file will be lost when recompiling UI file!
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
from PySide6.QtCharts import QChartView
|
||||||
|
from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
|
||||||
|
QMetaObject, QObject, QPoint, QRect,
|
||||||
|
QSize, QTime, QUrl, Qt)
|
||||||
|
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
|
||||||
|
QFont, QFontDatabase, QGradient, QIcon,
|
||||||
|
QImage, QKeySequence, QLinearGradient, QPainter,
|
||||||
|
QPalette, QPixmap, QRadialGradient, QTransform)
|
||||||
|
from PySide6.QtWidgets import (QApplication, QLabel, QSizePolicy, QTabWidget,
|
||||||
|
QWidget)
|
||||||
|
|
||||||
|
class Ui_PC_Monitor(object):
|
||||||
|
def setupUi(self, PC_Monitor):
|
||||||
|
if not PC_Monitor.objectName():
|
||||||
|
PC_Monitor.setObjectName(u"PC_Monitor")
|
||||||
|
PC_Monitor.resize(894, 673)
|
||||||
|
icon = QIcon()
|
||||||
|
icon.addFile(u"resources/app_icon.png", QSize(), QIcon.Mode.Normal, QIcon.State.Off)
|
||||||
|
PC_Monitor.setWindowIcon(icon)
|
||||||
|
self.PCMonitor = QTabWidget(PC_Monitor)
|
||||||
|
self.PCMonitor.setObjectName(u"PCMonitor")
|
||||||
|
self.PCMonitor.setGeometry(QRect(10, 40, 861, 581))
|
||||||
|
self.cpu = QWidget()
|
||||||
|
self.cpu.setObjectName(u"cpu")
|
||||||
|
self.cpu_title = QLabel(self.cpu)
|
||||||
|
self.cpu_title.setObjectName(u"cpu_title")
|
||||||
|
self.cpu_title.setGeometry(QRect(41, 41, 45, 27))
|
||||||
|
font = QFont()
|
||||||
|
font.setPointSize(16)
|
||||||
|
font.setBold(True)
|
||||||
|
self.cpu_title.setFont(font)
|
||||||
|
self.cpu_name = QLabel(self.cpu)
|
||||||
|
self.cpu_name.setObjectName(u"cpu_name")
|
||||||
|
self.cpu_name.setGeometry(QRect(600, 40, 219, 16))
|
||||||
|
self.cpu_percent_label = QLabel(self.cpu)
|
||||||
|
self.cpu_percent_label.setObjectName(u"cpu_percent_label")
|
||||||
|
self.cpu_percent_label.setGeometry(QRect(40, 330, 54, 16))
|
||||||
|
self.cpu_speed_label = QLabel(self.cpu)
|
||||||
|
self.cpu_speed_label.setObjectName(u"cpu_speed_label")
|
||||||
|
self.cpu_speed_label.setGeometry(QRect(120, 330, 54, 16))
|
||||||
|
self.cpu_basespeed_label = QLabel(self.cpu)
|
||||||
|
self.cpu_basespeed_label.setObjectName(u"cpu_basespeed_label")
|
||||||
|
self.cpu_basespeed_label.setGeometry(QRect(300, 320, 61, 16))
|
||||||
|
self.cpu_slot_label = QLabel(self.cpu)
|
||||||
|
self.cpu_slot_label.setObjectName(u"cpu_slot_label")
|
||||||
|
self.cpu_slot_label.setGeometry(QRect(300, 350, 54, 16))
|
||||||
|
self.cpu_kernel_label = QLabel(self.cpu)
|
||||||
|
self.cpu_kernel_label.setObjectName(u"cpu_kernel_label")
|
||||||
|
self.cpu_kernel_label.setGeometry(QRect(300, 380, 54, 16))
|
||||||
|
self.cpu_logicprocessor_label = QLabel(self.cpu)
|
||||||
|
self.cpu_logicprocessor_label.setObjectName(u"cpu_logicprocessor_label")
|
||||||
|
self.cpu_logicprocessor_label.setGeometry(QRect(300, 410, 71, 16))
|
||||||
|
self.cpu_virtualization_label = QLabel(self.cpu)
|
||||||
|
self.cpu_virtualization_label.setObjectName(u"cpu_virtualization_label")
|
||||||
|
self.cpu_virtualization_label.setGeometry(QRect(300, 440, 54, 16))
|
||||||
|
self.cpu_L1_cache_label = QLabel(self.cpu)
|
||||||
|
self.cpu_L1_cache_label.setObjectName(u"cpu_L1_cache_label")
|
||||||
|
self.cpu_L1_cache_label.setGeometry(QRect(300, 470, 54, 16))
|
||||||
|
self.cpu_L2_cache_label = QLabel(self.cpu)
|
||||||
|
self.cpu_L2_cache_label.setObjectName(u"cpu_L2_cache_label")
|
||||||
|
self.cpu_L2_cache_label.setGeometry(QRect(300, 490, 54, 16))
|
||||||
|
self.cpu_L3_cache_label = QLabel(self.cpu)
|
||||||
|
self.cpu_L3_cache_label.setObjectName(u"cpu_L3_cache_label")
|
||||||
|
self.cpu_L3_cache_label.setGeometry(QRect(300, 520, 54, 16))
|
||||||
|
self.cpu_process_label = QLabel(self.cpu)
|
||||||
|
self.cpu_process_label.setObjectName(u"cpu_process_label")
|
||||||
|
self.cpu_process_label.setGeometry(QRect(40, 400, 54, 16))
|
||||||
|
self.cpu_thread_label = QLabel(self.cpu)
|
||||||
|
self.cpu_thread_label.setObjectName(u"cpu_thread_label")
|
||||||
|
self.cpu_thread_label.setGeometry(QRect(90, 400, 54, 16))
|
||||||
|
self.cpu_handle_label = QLabel(self.cpu)
|
||||||
|
self.cpu_handle_label.setObjectName(u"cpu_handle_label")
|
||||||
|
self.cpu_handle_label.setGeometry(QRect(160, 400, 54, 16))
|
||||||
|
self.cpu_runningtime_label = QLabel(self.cpu)
|
||||||
|
self.cpu_runningtime_label.setObjectName(u"cpu_runningtime_label")
|
||||||
|
self.cpu_runningtime_label.setGeometry(QRect(40, 460, 81, 16))
|
||||||
|
self.graphicsView = QChartView(self.cpu)
|
||||||
|
self.graphicsView.setObjectName(u"graphicsView")
|
||||||
|
self.graphicsView.setGeometry(QRect(40, 90, 791, 192))
|
||||||
|
self.label_2 = QLabel(self.cpu)
|
||||||
|
self.label_2.setObjectName(u"label_2")
|
||||||
|
self.label_2.setGeometry(QRect(40, 70, 54, 16))
|
||||||
|
self.cpu_percent_max = QLabel(self.cpu)
|
||||||
|
self.cpu_percent_max.setObjectName(u"cpu_percent_max")
|
||||||
|
self.cpu_percent_max.setGeometry(QRect(790, 70, 54, 16))
|
||||||
|
self.time_stop = QLabel(self.cpu)
|
||||||
|
self.time_stop.setObjectName(u"time_stop")
|
||||||
|
self.time_stop.setGeometry(QRect(40, 290, 54, 16))
|
||||||
|
self.time_start = QLabel(self.cpu)
|
||||||
|
self.time_start.setObjectName(u"time_start")
|
||||||
|
self.time_start.setGeometry(QRect(810, 290, 51, 20))
|
||||||
|
self.cpu_percent_value = QLabel(self.cpu)
|
||||||
|
self.cpu_percent_value.setObjectName(u"cpu_percent_value")
|
||||||
|
self.cpu_percent_value.setGeometry(QRect(40, 360, 54, 16))
|
||||||
|
self.cpu_speed_value = QLabel(self.cpu)
|
||||||
|
self.cpu_speed_value.setObjectName(u"cpu_speed_value")
|
||||||
|
self.cpu_speed_value.setGeometry(QRect(120, 360, 54, 16))
|
||||||
|
self.cpu_process_value = QLabel(self.cpu)
|
||||||
|
self.cpu_process_value.setObjectName(u"cpu_process_value")
|
||||||
|
self.cpu_process_value.setGeometry(QRect(40, 420, 31, 16))
|
||||||
|
self.cpu_thread_value = QLabel(self.cpu)
|
||||||
|
self.cpu_thread_value.setObjectName(u"cpu_thread_value")
|
||||||
|
self.cpu_thread_value.setGeometry(QRect(90, 420, 54, 16))
|
||||||
|
self.cpu_handle_value = QLabel(self.cpu)
|
||||||
|
self.cpu_handle_value.setObjectName(u"cpu_handle_value")
|
||||||
|
self.cpu_handle_value.setGeometry(QRect(170, 420, 54, 16))
|
||||||
|
self.cpu_runningtime_value = QLabel(self.cpu)
|
||||||
|
self.cpu_runningtime_value.setObjectName(u"cpu_runningtime_value")
|
||||||
|
self.cpu_runningtime_value.setGeometry(QRect(40, 490, 121, 16))
|
||||||
|
self.cpu_basespeed_value = QLabel(self.cpu)
|
||||||
|
self.cpu_basespeed_value.setObjectName(u"cpu_basespeed_value")
|
||||||
|
self.cpu_basespeed_value.setGeometry(QRect(390, 320, 54, 16))
|
||||||
|
self.cpu_slot_value = QLabel(self.cpu)
|
||||||
|
self.cpu_slot_value.setObjectName(u"cpu_slot_value")
|
||||||
|
self.cpu_slot_value.setGeometry(QRect(390, 350, 54, 16))
|
||||||
|
self.cpu_kernel_value = QLabel(self.cpu)
|
||||||
|
self.cpu_kernel_value.setObjectName(u"cpu_kernel_value")
|
||||||
|
self.cpu_kernel_value.setGeometry(QRect(390, 380, 54, 16))
|
||||||
|
self.cpu_logicprocessor_value = QLabel(self.cpu)
|
||||||
|
self.cpu_logicprocessor_value.setObjectName(u"cpu_logicprocessor_value")
|
||||||
|
self.cpu_logicprocessor_value.setGeometry(QRect(390, 410, 54, 16))
|
||||||
|
self.cpu_virtualization_value = QLabel(self.cpu)
|
||||||
|
self.cpu_virtualization_value.setObjectName(u"cpu_virtualization_value")
|
||||||
|
self.cpu_virtualization_value.setGeometry(QRect(390, 440, 54, 16))
|
||||||
|
self.cpu_L1_cache_value = QLabel(self.cpu)
|
||||||
|
self.cpu_L1_cache_value.setObjectName(u"cpu_L1_cache_value")
|
||||||
|
self.cpu_L1_cache_value.setGeometry(QRect(390, 470, 54, 16))
|
||||||
|
self.cpu_L2_cache_value = QLabel(self.cpu)
|
||||||
|
self.cpu_L2_cache_value.setObjectName(u"cpu_L2_cache_value")
|
||||||
|
self.cpu_L2_cache_value.setGeometry(QRect(390, 490, 54, 16))
|
||||||
|
self.cpu_L3_cache_value = QLabel(self.cpu)
|
||||||
|
self.cpu_L3_cache_value.setObjectName(u"cpu_L3_cache_value")
|
||||||
|
self.cpu_L3_cache_value.setGeometry(QRect(390, 520, 54, 16))
|
||||||
|
self.PCMonitor.addTab(self.cpu, "")
|
||||||
|
self.memory = QWidget()
|
||||||
|
self.memory.setObjectName(u"memory")
|
||||||
|
self.PCMonitor.addTab(self.memory, "")
|
||||||
|
self.disk = QWidget()
|
||||||
|
self.disk.setObjectName(u"disk")
|
||||||
|
self.PCMonitor.addTab(self.disk, "")
|
||||||
|
self.network = QWidget()
|
||||||
|
self.network.setObjectName(u"network")
|
||||||
|
self.PCMonitor.addTab(self.network, "")
|
||||||
|
self.gpu = QWidget()
|
||||||
|
self.gpu.setObjectName(u"gpu")
|
||||||
|
self.PCMonitor.addTab(self.gpu, "")
|
||||||
|
|
||||||
|
self.retranslateUi(PC_Monitor)
|
||||||
|
|
||||||
|
self.PCMonitor.setCurrentIndex(0)
|
||||||
|
|
||||||
|
|
||||||
|
QMetaObject.connectSlotsByName(PC_Monitor)
|
||||||
|
# setupUi
|
||||||
|
|
||||||
|
def retranslateUi(self, PC_Monitor):
|
||||||
|
PC_Monitor.setWindowTitle(QCoreApplication.translate("PC_Monitor", u"PC_Monitor", None))
|
||||||
|
self.cpu_title.setText(QCoreApplication.translate("PC_Monitor", u"CPU", None))
|
||||||
|
self.cpu_name.setText(QCoreApplication.translate("PC_Monitor", u"13th Gen Inter(R) Core(TM) i5-13500H", None))
|
||||||
|
self.cpu_percent_label.setText(QCoreApplication.translate("PC_Monitor", u"\u5229\u7528\u7387", None))
|
||||||
|
self.cpu_speed_label.setText(QCoreApplication.translate("PC_Monitor", u"\u901f\u5ea6", None))
|
||||||
|
self.cpu_basespeed_label.setText(QCoreApplication.translate("PC_Monitor", u"\u57fa\u51c6\u901f\u5ea6:", None))
|
||||||
|
self.cpu_slot_label.setText(QCoreApplication.translate("PC_Monitor", u"\u63d2\u69fd:", None))
|
||||||
|
self.cpu_kernel_label.setText(QCoreApplication.translate("PC_Monitor", u"\u5185\u6838:", None))
|
||||||
|
self.cpu_logicprocessor_label.setText(QCoreApplication.translate("PC_Monitor", u"\u903b\u8f91\u5904\u7406\u5668:", None))
|
||||||
|
self.cpu_virtualization_label.setText(QCoreApplication.translate("PC_Monitor", u"\u865a\u62df\u5316:", None))
|
||||||
|
self.cpu_L1_cache_label.setText(QCoreApplication.translate("PC_Monitor", u"L1\u7f13\u5b58:", None))
|
||||||
|
self.cpu_L2_cache_label.setText(QCoreApplication.translate("PC_Monitor", u"L2 \u7f13\u5b58:", None))
|
||||||
|
self.cpu_L3_cache_label.setText(QCoreApplication.translate("PC_Monitor", u"L3\u7f13\u5b58:", None))
|
||||||
|
self.cpu_process_label.setText(QCoreApplication.translate("PC_Monitor", u"\u8fdb\u7a0b", None))
|
||||||
|
self.cpu_thread_label.setText(QCoreApplication.translate("PC_Monitor", u"\u7ebf\u7a0b", None))
|
||||||
|
self.cpu_handle_label.setText(QCoreApplication.translate("PC_Monitor", u"\u53e5\u67c4", None))
|
||||||
|
self.cpu_runningtime_label.setText(QCoreApplication.translate("PC_Monitor", u"\u6b63\u5e38\u8fd0\u884c\u65f6\u95f4", None))
|
||||||
|
self.label_2.setText(QCoreApplication.translate("PC_Monitor", u"% \u5229\u7528\u7387", None))
|
||||||
|
self.cpu_percent_max.setText(QCoreApplication.translate("PC_Monitor", u"100%", None))
|
||||||
|
self.time_stop.setText(QCoreApplication.translate("PC_Monitor", u"60\u79d2", None))
|
||||||
|
self.time_start.setText(QCoreApplication.translate("PC_Monitor", u"0", None))
|
||||||
|
self.cpu_percent_value.setText(QCoreApplication.translate("PC_Monitor", u"0", None))
|
||||||
|
self.cpu_speed_value.setText(QCoreApplication.translate("PC_Monitor", u"0", None))
|
||||||
|
self.cpu_process_value.setText(QCoreApplication.translate("PC_Monitor", u"0", None))
|
||||||
|
self.cpu_thread_value.setText(QCoreApplication.translate("PC_Monitor", u"0", None))
|
||||||
|
self.cpu_handle_value.setText(QCoreApplication.translate("PC_Monitor", u"0", None))
|
||||||
|
self.cpu_runningtime_value.setText(QCoreApplication.translate("PC_Monitor", u"0", None))
|
||||||
|
self.cpu_basespeed_value.setText(QCoreApplication.translate("PC_Monitor", u"0", None))
|
||||||
|
self.cpu_slot_value.setText(QCoreApplication.translate("PC_Monitor", u"0", None))
|
||||||
|
self.cpu_kernel_value.setText(QCoreApplication.translate("PC_Monitor", u"0", None))
|
||||||
|
self.cpu_logicprocessor_value.setText(QCoreApplication.translate("PC_Monitor", u"0", None))
|
||||||
|
self.cpu_virtualization_value.setText(QCoreApplication.translate("PC_Monitor", u"0", None))
|
||||||
|
self.cpu_L1_cache_value.setText(QCoreApplication.translate("PC_Monitor", u"0", None))
|
||||||
|
self.cpu_L2_cache_value.setText(QCoreApplication.translate("PC_Monitor", u"0", None))
|
||||||
|
self.cpu_L3_cache_value.setText(QCoreApplication.translate("PC_Monitor", u"0", None))
|
||||||
|
self.PCMonitor.setTabText(self.PCMonitor.indexOf(self.cpu), QCoreApplication.translate("PC_Monitor", u"CPU", None))
|
||||||
|
self.PCMonitor.setTabText(self.PCMonitor.indexOf(self.memory), QCoreApplication.translate("PC_Monitor", u"\u5185\u5b58", None))
|
||||||
|
self.PCMonitor.setTabText(self.PCMonitor.indexOf(self.disk), QCoreApplication.translate("PC_Monitor", u"\u78c1\u76d8", None))
|
||||||
|
self.PCMonitor.setTabText(self.PCMonitor.indexOf(self.network), QCoreApplication.translate("PC_Monitor", u"\u7f51\u7edc", None))
|
||||||
|
self.PCMonitor.setTabText(self.PCMonitor.indexOf(self.gpu), QCoreApplication.translate("PC_Monitor", u"GPU", None))
|
||||||
|
# retranslateUi
|
||||||
|
|
121
main.py
Normal file
121
main.py
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
import datetime
|
||||||
|
import sys
|
||||||
|
import psutil
|
||||||
|
import wmi
|
||||||
|
from PySide6 import QtCharts
|
||||||
|
from PySide6.QtCore import QDateTime, QTimer
|
||||||
|
from PySide6.QtGui import Qt
|
||||||
|
from PySide6.QtWidgets import QWidget, QApplication
|
||||||
|
|
||||||
|
from PC_Monitor import Ui_PC_Monitor
|
||||||
|
|
||||||
|
import win32com.client
|
||||||
|
|
||||||
|
def get_total_thread_count_pywin32():
|
||||||
|
"""使用 pywin32 获取系统总线程数"""
|
||||||
|
wmi = win32com.client.GetObject("winmgmts:")
|
||||||
|
processes = wmi.InstancesOf("Win32_Process")
|
||||||
|
return sum(int(p.Properties_("ThreadCount").Value) for p in processes)
|
||||||
|
|
||||||
|
|
||||||
|
def get_total_handle_count():
|
||||||
|
"""获取系统中所有进程的句柄总数"""
|
||||||
|
total_handles = 0
|
||||||
|
for proc in psutil.process_iter(['pid', 'name', 'num_handles']):
|
||||||
|
try:
|
||||||
|
total_handles += proc.info['num_handles']
|
||||||
|
except (psutil.NoSuchProcess, psutil.AccessDenied):
|
||||||
|
continue
|
||||||
|
return total_handles
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class MyWindow(QWidget):
|
||||||
|
def __init__(self,parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
self.c = wmi.WMI()
|
||||||
|
|
||||||
|
self.ui = Ui_PC_Monitor() # 创建UI对象
|
||||||
|
self.ui.setupUi(self) # 构造UI界面
|
||||||
|
self.create_chart()
|
||||||
|
self.set_timer()
|
||||||
|
|
||||||
|
|
||||||
|
self.setWindowTitle("电脑系统监控")
|
||||||
|
|
||||||
|
|
||||||
|
def create_chart(self):
|
||||||
|
self.chart = QtCharts.QChart()
|
||||||
|
self.series = QtCharts.QLineSeries()
|
||||||
|
self.chart.addSeries(self.series)
|
||||||
|
self.chart.legend().hide()
|
||||||
|
|
||||||
|
#设置坐标轴显示范围
|
||||||
|
self.data_axisX = QtCharts.QDateTimeAxis()
|
||||||
|
self.value_axisY = QtCharts.QValueAxis()
|
||||||
|
|
||||||
|
self.limitminute = 1 #设置显示多少分钟内活动
|
||||||
|
self.maxspeed = 100 # 预设y轴最大值
|
||||||
|
#Returns a QDateTime object containing a datetime a seconds later than the datetime of this object (or earlier if s is negative).
|
||||||
|
self.data_axisX.setMin(QDateTime.currentDateTime().addSecs(-self.limitminute*60))
|
||||||
|
self.data_axisX.setMax(QDateTime.currentDateTime().addSecs(0))
|
||||||
|
self.value_axisY.setMin(0)
|
||||||
|
self.value_axisY.setMax(self.maxspeed)
|
||||||
|
self.data_axisX.setFormat("hh:mm:ss")
|
||||||
|
#把坐标轴添加到 chart 中
|
||||||
|
self.chart.addAxis(self.data_axisX,Qt.AlignmentFlag.AlignBottom)
|
||||||
|
self.chart.addAxis(self.value_axisY,Qt.AlignmentFlag.AlignLeft)
|
||||||
|
|
||||||
|
# 把曲线关联到坐标轴
|
||||||
|
self.series.attachAxis(self.data_axisX)
|
||||||
|
self.series.attachAxis(self.value_axisY)
|
||||||
|
self.ui.graphicsView.setChart(self.chart)
|
||||||
|
|
||||||
|
self.ui.cpu_L2_cache_value.setText(str(self.c.Win32_Processor()[0].L2CacheSize / 1024)+' MB')
|
||||||
|
self.ui.cpu_L3_cache_value.setText(str(self.c.Win32_Processor()[0].L3CacheSize / 1024)+' MB')
|
||||||
|
# print("系统名称: "+self.c.Win32_OperatingSystem()[0].Caption)
|
||||||
|
|
||||||
|
cpufreq = psutil.cpu_freq()
|
||||||
|
self.ui.cpu_kernel_value.setText(str(psutil.cpu_count(logical=False)))
|
||||||
|
self.ui.cpu_logicprocessor_value.setText(str(psutil.cpu_count(logical=True)))
|
||||||
|
self.ui.cpu_basespeed_value.setText(str('%.2f'% (cpufreq.current/1000))+' GHz')
|
||||||
|
self.ui.cpu_name.setText(str(self.c.Win32_Processor()[0].Name))
|
||||||
|
|
||||||
|
|
||||||
|
def set_timer(self):
|
||||||
|
self.timer = QTimer(self)
|
||||||
|
self.timer.timeout.connect(self.cpuLoad)
|
||||||
|
self.timer.start(1000) # 每隔200毫秒出一个点
|
||||||
|
|
||||||
|
def cpuLoad(self):
|
||||||
|
current_time = QDateTime.currentDateTime()
|
||||||
|
self.data_axisX.setMin(current_time.addSecs(-self.limitminute*60))
|
||||||
|
self.data_axisX.setMax(current_time.addSecs(0))
|
||||||
|
cpuload = psutil.cpu_percent()
|
||||||
|
self.series.append(current_time.toMSecsSinceEpoch(),cpuload)
|
||||||
|
if self.series.at(0):
|
||||||
|
# Returns the datetime as the number of milliseconds that have passed since 1970-01-01T00:00:00.000,Coordinated Universal Time(UTC)
|
||||||
|
if self.series.at(0).x()<current_time.addSecs(-self.limitminute*60).toMSecsSinceEpoch():
|
||||||
|
self.series.remove(0)
|
||||||
|
self.ui.cpu_percent_value.setText(str(cpuload)+'%')
|
||||||
|
self.ui.cpu_runningtime_value.setText(str(datetime.datetime.fromtimestamp(psutil.boot_time()).strftime("%d:%H:%M:%S")))
|
||||||
|
self.ui.cpu_process_value.setText(str(len(psutil.pids())))
|
||||||
|
|
||||||
|
self.ui.cpu_thread_value.setText(str(get_total_thread_count_pywin32()))
|
||||||
|
|
||||||
|
self.ui.cpu_handle_value.setText(str(get_total_handle_count()))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app = QApplication(sys.argv)
|
||||||
|
|
||||||
|
window = MyWindow()
|
||||||
|
window.show()
|
||||||
|
sys.exit(app.exec())
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user