RELEASE 3.2.0

This commit is contained in:
MikeTheWatchGuy 2018-09-14 11:54:10 -04:00
parent 317f90b0c5
commit 4f43f7bcaf
3 changed files with 91 additions and 36 deletions

View File

@ -1,7 +1,10 @@
import PySimpleGUI as sg import PySimpleGUI as sg
import psutil import psutil
import time
from threading import Thread
import operator import operator
""" """
PSUTIL Desktop Widget PSUTIL Desktop Widget
Creates a floating CPU utilization window that is always on top of other windows Creates a floating CPU utilization window that is always on top of other windows
@ -14,17 +17,36 @@ import operator
invalid command name "1616802625480StopMove" invalid command name "1616802625480StopMove"
""" """
# ---------------- Create Form ----------------
sg.ChangeLookAndFeel('Black')
form_rows = [[sg.Text('', size=(8,1), font=('Helvetica', 20),text_color=sg.YELLOWS[0], justification='center', key='text')],
[sg.Text('', size=(30, 8), font=('Courier', 10),text_color='white', justification='left', key='processes')],
[sg.Exit(button_color=('white', 'firebrick4'), pad=((15,0), 0)), sg.Spin([x+1 for x in range(10)], 1, key='spin')]]
form = sg.FlexForm('CPU Utilization', no_titlebar=True, auto_size_buttons=False, keep_on_top=True, grab_anywhere=True) g_interval = 1
form.Layout(form_rows) g_cpu_percent = 0
g_procs = None
g_exit = False
# ---------------- main loop ---------------- def CPU_thread(args):
while (True): global g_interval, g_cpu_percent, g_procs, g_exit
while not g_exit:
g_cpu_percent = psutil.cpu_percent(interval=g_interval)
g_procs = psutil.process_iter()
def main():
global g_interval, g_procs, g_exit
# ---------------- Create Form ----------------
sg.ChangeLookAndFeel('Black')
form_rows = [[sg.Text('', size=(8,1), font=('Helvetica', 20),text_color=sg.YELLOWS[0], justification='center', key='text')],
[sg.Text('', size=(30, 8), font=('Courier New', 12),text_color='white', justification='left', key='processes')],
[sg.Exit(button_color=('white', 'firebrick4'), pad=((15,0), 0)), sg.Spin([x+1 for x in range(10)], 1, key='spin')],
]
form = sg.FlexForm('CPU Utilization', no_titlebar=True, auto_size_buttons=False, keep_on_top=True, grab_anywhere=True)
form.Layout(form_rows)
thread = Thread(target=CPU_thread,args=(None,))
thread.start()
# ---------------- main loop ----------------
while (True):
# --------- Read and update window -------- # --------- Read and update window --------
button, values = form.ReadNonBlocking() button, values = form.ReadNonBlocking()
@ -32,25 +54,36 @@ while (True):
if values is None or button == 'Exit': if values is None or button == 'Exit':
break break
try: try:
interval = int(values['spin']) g_interval = int(values['spin'])
except: except:
interval = 1 g_interval = 1
cpu_percent = psutil.cpu_percent(interval=interval) # cpu_percent = psutil.cpu_percent(interval=interval)
cpu_percent = g_cpu_percent
time.sleep(.1)
display_string = ''
if g_procs:
# --------- Create list of top % CPU porocesses -------- # --------- Create list of top % CPU porocesses --------
top = {proc.name() : proc.cpu_percent() for proc in psutil.process_iter()} top = {proc.name() : proc.cpu_percent() for proc in g_procs}
top_sorted = sorted(top.items(), key=operator.itemgetter(1), reverse=True) top_sorted = sorted(top.items(), key=operator.itemgetter(1), reverse=True)
if top_sorted:
top_sorted.pop(0) top_sorted.pop(0)
display_string = '' display_string = ''
for proc, cpu in top_sorted: for proc, cpu in top_sorted:
display_string += '{} {}\n'.format(cpu, proc) display_string += '{} {}\n'.format(cpu, proc)
# --------- Display timer in window -------- # --------- Display timer in window --------
form.FindElement('text').Update('CPU {}'.format(cpu_percent)) form.FindElement('text').Update('CPU {}'.format(cpu_percent))
# form.FindElement('processes').Update('\n'.join(top_sorted))
form.FindElement('processes').Update(display_string) form.FindElement('processes').Update(display_string)
# Broke out of main loop. Close the window. # Broke out of main loop. Close the window.
form.CloseNonBlockingForm() form.CloseNonBlockingForm()
g_exit = True
thread.join()
exit(69)
if __name__ == "__main__":
main()

View File

@ -11,7 +11,7 @@
# PySimpleGUI # PySimpleGUI
(Ver 3.1.2) (Ver 3.2.0)
@ -222,9 +222,17 @@ Some users have found that upgrading required using an extra flag on the pip `--
pip install --upgrade --no-cache-dir PySimpleGUI==3.0.3 pip install --upgrade --no-cache-dir PySimpleGUI==3.0.3
If for some reason you are unable to install using `pip`, don't worry, you can still import PySimpleGUI by downloading the file PySimleGUI.py and placing it in your folder along with the application that is importing it. If for some reason you are unable to install using `pip`, don't worry, you can still import PySimpleGUI by downloading the file PySimleGUI.py and placing it in your folder along with the application that is importing it.
`tkinter` is a requirement for PySimpleGUI (the only requirement). Some OS variants, such as Ubuntu, do not some with `tkinter` already installed. If you get an error similar to:
```
ImportError: No module named tkinter
```
then you need to install `tkinter`. Be sure and get the Python 3 version.
```
sudo apt-get install python3-tk
```
### Prerequisites ### Prerequisites
@ -2167,6 +2175,7 @@ A MikeTheWatchGuy production... entirely responsible for this code.... unless it
| 3.0.0 | Sept 7, 2018 - The "fix for poor choice of 2.x numbers" release. Color Chooser (button), "grab anywhere" windows are on by default, disable combo boxes, Input Element text justification (last part needed for 'tables'), Image Element changes to support OpenCV?, PopupGetFile and PopupGetFolder have better no_window option | 3.0.0 | Sept 7, 2018 - The "fix for poor choice of 2.x numbers" release. Color Chooser (button), "grab anywhere" windows are on by default, disable combo boxes, Input Element text justification (last part needed for 'tables'), Image Element changes to support OpenCV?, PopupGetFile and PopupGetFolder have better no_window option
| 3.01.01 | Sept 10, 2018 - Menus! (sort of a big deal) | 3.01.01 | Sept 10, 2018 - Menus! (sort of a big deal)
| 3.01.02 | Step 11, 2018 - All Element.Update functions have a `disabled` parameter so they can be disabled. Renamed some parameters in Update function (sorry if I broke your code), fix for bug in Image.Update. Wasn't setting size correctly, changed grab_anywhere logic again,added grab anywhere option to PupupGetText (assumes disabled) | 3.01.02 | Step 11, 2018 - All Element.Update functions have a `disabled` parameter so they can be disabled. Renamed some parameters in Update function (sorry if I broke your code), fix for bug in Image.Update. Wasn't setting size correctly, changed grab_anywhere logic again,added grab anywhere option to PupupGetText (assumes disabled)
| 3.02.00 | Sept 14, 2018 - New Table Element (Beta release), MsgBox removed entirely, font setting for InputText Element, **packing change** risky change that allows some Elements to be resized,removed command parameter from Menu Element, new function names for ReadNonBlocking (Finalize, PreRead), change to text element autosizing and wrapping (yet again), lots of parameter additions to Popup functions (colors, etc).
### Release Notes ### Release Notes
@ -2196,6 +2205,8 @@ Related to the Grab Anywhere feature is the no_titlebar option, again found in t
3.0.2 Still making changes to Update methods with many more ahead in the future. Continue to mess with grab anywhere option. Needed to disable in more places such as the PopupGetText function. Any time these is text input on a form, you generally want to turn off the grab anywhere feature. 3.0.2 Still making changes to Update methods with many more ahead in the future. Continue to mess with grab anywhere option. Needed to disable in more places such as the PopupGetText function. Any time these is text input on a form, you generally want to turn off the grab anywhere feature.
3.2.0 Biggest change was the addition of the Table Element. Trying to make changes so that form resizing is a possibility but unknown if will work in the long run. Removed all MsgBox, Get* functions and replaced with Popup functions. Popups had multiple new parameters added to change the look and feel of a popup.
### Upcoming ### Upcoming
Make suggestions people! Future release features Make suggestions people! Future release features

View File

@ -11,7 +11,7 @@
# PySimpleGUI # PySimpleGUI
(Ver 3.1.2) (Ver 3.2.0)
@ -222,9 +222,17 @@ Some users have found that upgrading required using an extra flag on the pip `--
pip install --upgrade --no-cache-dir PySimpleGUI==3.0.3 pip install --upgrade --no-cache-dir PySimpleGUI==3.0.3
If for some reason you are unable to install using `pip`, don't worry, you can still import PySimpleGUI by downloading the file PySimleGUI.py and placing it in your folder along with the application that is importing it. If for some reason you are unable to install using `pip`, don't worry, you can still import PySimpleGUI by downloading the file PySimleGUI.py and placing it in your folder along with the application that is importing it.
`tkinter` is a requirement for PySimpleGUI (the only requirement). Some OS variants, such as Ubuntu, do not some with `tkinter` already installed. If you get an error similar to:
```
ImportError: No module named tkinter
```
then you need to install `tkinter`. Be sure and get the Python 3 version.
```
sudo apt-get install python3-tk
```
### Prerequisites ### Prerequisites
@ -2167,6 +2175,7 @@ A MikeTheWatchGuy production... entirely responsible for this code.... unless it
| 3.0.0 | Sept 7, 2018 - The "fix for poor choice of 2.x numbers" release. Color Chooser (button), "grab anywhere" windows are on by default, disable combo boxes, Input Element text justification (last part needed for 'tables'), Image Element changes to support OpenCV?, PopupGetFile and PopupGetFolder have better no_window option | 3.0.0 | Sept 7, 2018 - The "fix for poor choice of 2.x numbers" release. Color Chooser (button), "grab anywhere" windows are on by default, disable combo boxes, Input Element text justification (last part needed for 'tables'), Image Element changes to support OpenCV?, PopupGetFile and PopupGetFolder have better no_window option
| 3.01.01 | Sept 10, 2018 - Menus! (sort of a big deal) | 3.01.01 | Sept 10, 2018 - Menus! (sort of a big deal)
| 3.01.02 | Step 11, 2018 - All Element.Update functions have a `disabled` parameter so they can be disabled. Renamed some parameters in Update function (sorry if I broke your code), fix for bug in Image.Update. Wasn't setting size correctly, changed grab_anywhere logic again,added grab anywhere option to PupupGetText (assumes disabled) | 3.01.02 | Step 11, 2018 - All Element.Update functions have a `disabled` parameter so they can be disabled. Renamed some parameters in Update function (sorry if I broke your code), fix for bug in Image.Update. Wasn't setting size correctly, changed grab_anywhere logic again,added grab anywhere option to PupupGetText (assumes disabled)
| 3.02.00 | Sept 14, 2018 - New Table Element (Beta release), MsgBox removed entirely, font setting for InputText Element, **packing change** risky change that allows some Elements to be resized,removed command parameter from Menu Element, new function names for ReadNonBlocking (Finalize, PreRead), change to text element autosizing and wrapping (yet again), lots of parameter additions to Popup functions (colors, etc).
### Release Notes ### Release Notes
@ -2196,6 +2205,8 @@ Related to the Grab Anywhere feature is the no_titlebar option, again found in t
3.0.2 Still making changes to Update methods with many more ahead in the future. Continue to mess with grab anywhere option. Needed to disable in more places such as the PopupGetText function. Any time these is text input on a form, you generally want to turn off the grab anywhere feature. 3.0.2 Still making changes to Update methods with many more ahead in the future. Continue to mess with grab anywhere option. Needed to disable in more places such as the PopupGetText function. Any time these is text input on a form, you generally want to turn off the grab anywhere feature.
3.2.0 Biggest change was the addition of the Table Element. Trying to make changes so that form resizing is a possibility but unknown if will work in the long run. Removed all MsgBox, Get* functions and replaced with Popup functions. Popups had multiple new parameters added to change the look and feel of a popup.
### Upcoming ### Upcoming
Make suggestions people! Future release features Make suggestions people! Future release features