Moved all demo programs into subfolder
This commit is contained in:
parent
a294d0a347
commit
1881bd7126
107 changed files with 51 additions and 144 deletions
18
DemoPrograms/TutorialCPUUtilization.py
Normal file
18
DemoPrograms/TutorialCPUUtilization.py
Normal 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}%')
|
Loading…
Add table
Add a link
Reference in a new issue