程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

[Python monitoring CPU] a super healing runcat monitoring application system has been launched ~ its very popular, and its appearance is full

編輯:Python

Introduction

hello ! I'm kimiko , I'm so lazy recently. It's too hot .jpg

I have time to update you ! Online today —— Write a sister article with this article ~

【Python Too cattle 】 A powerful real-time monitoring CPU Usage rate Professional tools are fresh ~

  In the use of Mac Computer office , Sometimes you don't know which software or processes will take up a lot of money Source , Lead to other tasks

appear Slow down 、 Carton And so on . therefore , real time The monitoring system Resources become very important .

But there are a variety of system monitoring software on the market , A wide variety , Which monitoring software is the best

​ Today, I will introduce a super easy-to-use Mac Monitoring software running cat , Hope it can be helpful to your choice .

  Uh huh ~win10 The computer said it was not satisfied ,Mac Can have , I can't do less ,SO One A cat monitoring applet of the cure system is made

La ~ I would like to introduce my Tuanzi : I remember it was Second appearance Is that right ~ Ha ha ha

Text

One 、 brief introduction

1.1  The software is introduced

Used to Mac You may know such a software :RunCat.

This is a healing system Mac System monitoring software , It can reside in your system status bar in the form of animation .

Cat can tell you by running speed Mac Of CPU Usage rate . and RunCat Provides keyframe animation for the menu bar , The animation is based on Mac Of  CPU Usage change speed .

Of course RunCat Not just cats , There are many animals and animations , such as :

cat — Dog — Cheetah — The rabbit — The dolphins — frog — bird — penguin — Long dragon — gear ️— fire — Water drop — The rockets — Ring ️—— wait .

This application does not have enough advantages in terms of function , But I can't stand it. It's fun . ha-ha Xiaobian likes to introduce some interesting things to everyone ~

In addition, it comes with many free animations , Generally speaking, it is enough .RunCat It is a software that is more suitable for curing boredom in a daze !

Two 、 In preparation

2.0 Introduction of the principle

The principle is very simple , utilize python Of psutil Bag can easily get the current computer CPU Utilization or running memory

Utilization rate . Then determine the update frequency of the tray icon according to the utilization rate .

Then set by cycling 5 In different states icon To achieve the effect of running , Interested friends can make their own favorite

And then replace what I found OK La ~

2.1 Environmental installation

Python3、Pycharm. Related modules :psutil modular ; As well as some python Built in modules .

Douban image source is used for module installation :

pip install -i https://pypi.douban.com/simple/ + Module name 

2.2 Material preparation ( Modifiable )

Cat can tell you by running speed Mac Of CPU Usage rate , It is mainly a small script made by cat , Other animals can try to do it by themselves ~

3、 ... and 、 Start typing code

3.1 The import module

import sys
import time
import psutil
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QApplication, QSystemTrayIcon

3.2  A running cat -CPU

def runcatCPU():
app = QApplication(sys.argv)
# The program does not exit when the last visible window exits
app.setQuitOnLastWindowClosed(False)
icon = QSystemTrayIcon()
icon.setIcon(QIcon('icons/0.png'))
icon.setVisible(True)
cpu_percent = psutil.cpu_percent(interval=1) / 100
cpu_percent_update_fps = 20
fps_count = 0
while True:
fps_count += 1
if fps_count > cpu_percent_update_fps:
cpu_percent = psutil.cpu_percent(interval=1) / 100
fps_count = 0
# A parabola with an upward opening , Decrease on the left
time_interval = (cpu_percent * cpu_percent - 2 * cpu_percent + 2) / 20
for i in range(5):
icon.setIcon(QIcon('icons/%d.png' % i))
icon.setToolTip('cpu: %.2f' % cpu_percent)
time.sleep(time_interval)
app.exec_()

3.3  A running cat - Memory

def runcatMemory():
app = QApplication(sys.argv)
# The program does not exit when the last visible window exits
app.setQuitOnLastWindowClosed(False)
icon = QSystemTrayIcon()
icon.setIcon(QIcon('icons/0.png'))
icon.setVisible(True)
memory_percent = psutil.virtual_memory().percent / 100
memory_percent_update_fps = 20
fps_count = 0
while True:
fps_count += 1
if fps_count > memory_percent_update_fps:
memory_percent = psutil.virtual_memory().percent / 100
fps_count = 0
# A parabola with an upward opening , Decrease on the left
time_interval = (memory_percent * memory_percent - 2 * memory_percent + 2) / 20
for i in range(5):
icon.setIcon(QIcon('icons/%d.png' % i))
icon.setToolTip('memory: %.2f' % memory_percent)
time.sleep(time_interval)
app.exec_()

Four 、 Effect display

4.1 Dynamic video display effect ——

  

Runcat A running cat

4.2 Static screenshot shows the effect ——

summary

All right. ~ This article ends here , If you need to try it yourself, hurry up ~

Complete free source code collection office : Find me ! At the end of the article, you can get it by yourself , Didi, I can also !

It is recommended to read the previous articles ——

  project 3.1    Matting artifact

【 Praise 】 This kind of Python Applet automatic matting only needs 5 second , seckill PS Manual matting ?

  project 3.2   Opencv Collection 3 Fairy code

【OpenCV A collection of cases 】 There is such a fairy code , I love you ...... Interesting. ( attach 3 Source code )

project 1.0  Cartoon avatar

【Opencv actual combat 】 How fast Get Exclusive Avatar ? jing — I finally found the picture my girlfriend wanted ~

project 1.1  Anime characters

【 Break through the wall of dimension 】 Who says the second dimension is far away from us ?Python Special effects fire all over the network , The key technology turns out to be it .

A summary of the article ——

project 1.0 Python—2021 | Summary of existing articles | Continuous updating , Just read this article directly

( More + The source code is summarized in the article !! Welcome to ~)


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved