Merge pull request #397 from MikeTheWatchGuy/Dev-latest

YouTube Tutorial - Floating CPU meter
This commit is contained in:
MikeTheWatchGuy 2018-10-01 17:13:28 -04:00 committed by GitHub
commit fac9d24ffc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 0 deletions

18
TutorialCPUUtilization.py Normal file
View File

@ -0,0 +1,18 @@
import PySimpleGUI as sg
import psutil
layout = [ [sg.Text('CPU Utilization')] ,
[sg.Text('', size=(8,2), font='Helvetica 20', justification='center', key='_text_')],
[sg.Exit()]]
window = sg.Window('CPU Meter').Layout(layout)
while True:
button, values = window.ReadNonBlocking()
if button == 'Exit' or values is None:
break
cpu_percent = psutil.cpu_percent(interval=1)
window.FindElement('_text_').Update(f'CPU {cpu_percent:02.0f}%')