Merge pull request #172 from MikeTheWatchGuy/Dev-latest

Dev latest
This commit is contained in:
MikeTheWatchGuy 2018-09-08 19:37:58 -04:00 committed by GitHub
commit 4cef5d000d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 140 additions and 12 deletions

View File

@ -40,5 +40,6 @@ def Everything():
sg.Popup('Title', 'The results of the form.', 'The button clicked was "{}"'.format(button), 'The values are', values)
Everything()
if __name__ == '__main__':
Everything()

77
Demo_Floating_Toolbar.py Normal file
View File

@ -0,0 +1,77 @@
import PySimpleGUI as sg
import subprocess
import os
import sys
"""
Demo_Toolbar - A floating toolbar with quick launcher
One cool PySimpleGUI demo. Shows borderless windows, grab_anywhere, tight button layout
You can setup a specific program to launch when a button is clicked, or use the
Combobox to select a .py file found in the root folder, and run that file.
"""
ROOT_PATH = './'
def Launcher():
def print(line):
form.FindElement('output').Update(line)
sg.ChangeLookAndFeel('Dark')
namesonly = [f for f in os.listdir(ROOT_PATH) if f.endswith('.py') ]
sg.SetOptions(element_padding=(0,0), button_element_size=(12,1), auto_size_buttons=False)
layout = [[sg.Combo(values=namesonly, size=(35,30), key='demofile'),
sg.ReadFormButton('Run', button_color=('white', '#00168B')),
sg.ReadFormButton('Program 1'),
sg.ReadFormButton('Program 2'),
sg.ReadFormButton('Program 3', button_color=('white', '#35008B')),
sg.SimpleButton('EXIT', button_color=('white','firebrick3'))],
[sg.T('', text_color='white', size=(50,1), key='output')]]
form = sg.FlexForm('Floating Toolbar', no_titlebar=True, keep_on_top=True)
form.Layout(layout)
# ---===--- Loop taking in user input and using it to query HowDoI --- #
while True:
(button, value) = form.Read()
if button is 'EXIT' or button is None:
break # exit button clicked
if button is 'Program 1':
print('Run your program 1 here!')
elif button is 'Program 2':
print('Run your program 2 here!')
elif button is 'Run':
file = value['demofile']
print('Launching %s'%file)
ExecuteCommandSubprocess('python', os.path.join(ROOT_PATH, file))
else:
print(button)
def ExecuteCommandSubprocess(command, *args, wait=False):
try:
if sys.platform == 'linux':
arg_string = ''
for arg in args:
arg_string += ' ' + str(arg)
sp = subprocess.Popen(['python3' + arg_string, ], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
else:
sp = subprocess.Popen([command, list(args)], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if wait:
out, err = sp.communicate()
if out:
print(out.decode("utf-8"))
if err:
print(err.decode("utf-8"))
except: pass
if __name__ == '__main__':
Launcher()

View File

@ -7,7 +7,7 @@ def Timer():
sg.ChangeLookAndFeel('Dark')
sg.SetOptions(element_padding=(0,0))
# Make a form, but don't use context manager
form = sg.FlexForm('Running Timer', grab_anywhere=False, no_titlebar=True, auto_size_buttons=False)
form = sg.FlexForm('Running Timer', no_titlebar=True, auto_size_buttons=False)
# Create a text element that will be updated with status information on the GUI itself
# Create the rows
form_rows = [[sg.Text('')],

View File

@ -11,7 +11,7 @@
# PySimpleGUI
(Ver 3.00)
(Ver 3.00.02)
@ -199,11 +199,11 @@ You will see a number of different styles of buttons, data entry fields, etc, in
### Installing
pip install PySimpleGUI
pip install --upgrade PySimpleGUI
On some systems you need to run pip3.
pip3 install PySimpleGUI
pip3 install --upgrade PySimpleGUI
On a Raspberry Pi, this is should work:
@ -824,7 +824,8 @@ This is the definition of the FlexForm object:
use_default_focus=True,
text_justification=None,
no_titlebar=False,
grab_anywhere=True):
grab_anywhere=True
keep_on_top=False):
Parameter Descriptions. You will find these same parameters specified for each `Element` and some of them in `Row` specifications. The `Element` specified value will take precedence over the `Row` and `Form` values.
@ -849,6 +850,7 @@ Parameter Descriptions. You will find these same parameters specified for each
text_justification - Justification to use for Text Elements in this form
no_titlebar - Create window without a titlebar
grab_anywhere - Grab any location on the window to move the window
keep_on_top - if True then window will always stop on top of other windows on the screen. Great for floating toolbars.
#### Window Location
@ -865,6 +867,29 @@ In addition to `size` there is a `scale` option. `scale` will take the Element'
There are a couple of widgets where one of the size values is in pixels rather than characters. This is true for Progress Meters and Sliders. The second parameter is the 'height' in pixels.
#### No Titlebar
Should you wish to create cool looking windows that are clean with no windows titlebar, use the no_titlebar option when creating the window.
Be sure an provide your user an "exit" button or they will not be able to close the window! When no titlebar is enabled, there will be no icon on your taskbar for the window. Without an exit button you will need to kill via taskmanager... not fun.
Windows with no titlebar rely on the grab anywhere option to be enabled or else you will be unable to move the window.
Windows without a titlebar can be used to easily create a floating launcher.
![floating launcher](https://user-images.githubusercontent.com/13696193/45258246-71bafb80-b382-11e8-9f5e-79421e6c00bb.jpg)
#### Grab Anywhere
This is a feature unique to PySimpleGUI. The default is ENABLED.... unless the form is a non-blocking form.
It is turned off for non-blocking because there is a warning message printed out if the user closes a non-blocking form using a button with grab_anywhere enabled. There is no harm in these messages, but it may be distressing to the user. Should you wish to enable for a non-blocking form, simply get grab_anywhere = True when you create the form.
#### Always on top
To keep a window on top of all other windows on the screen, set keep_on_top = True when the form is created. This feature makes for floating toolbars that are very helpful and always visible on your desktop.
## Elements

View File

@ -11,7 +11,7 @@
# PySimpleGUI
(Ver 3.00)
(Ver 3.00.02)
@ -199,11 +199,11 @@ You will see a number of different styles of buttons, data entry fields, etc, in
### Installing
pip install PySimpleGUI
pip install --upgrade PySimpleGUI
On some systems you need to run pip3.
pip3 install PySimpleGUI
pip3 install --upgrade PySimpleGUI
On a Raspberry Pi, this is should work:
@ -824,7 +824,8 @@ This is the definition of the FlexForm object:
use_default_focus=True,
text_justification=None,
no_titlebar=False,
grab_anywhere=True):
grab_anywhere=True
keep_on_top=False):
Parameter Descriptions. You will find these same parameters specified for each `Element` and some of them in `Row` specifications. The `Element` specified value will take precedence over the `Row` and `Form` values.
@ -849,6 +850,7 @@ Parameter Descriptions. You will find these same parameters specified for each
text_justification - Justification to use for Text Elements in this form
no_titlebar - Create window without a titlebar
grab_anywhere - Grab any location on the window to move the window
keep_on_top - if True then window will always stop on top of other windows on the screen. Great for floating toolbars.
#### Window Location
@ -865,6 +867,29 @@ In addition to `size` there is a `scale` option. `scale` will take the Element'
There are a couple of widgets where one of the size values is in pixels rather than characters. This is true for Progress Meters and Sliders. The second parameter is the 'height' in pixels.
#### No Titlebar
Should you wish to create cool looking windows that are clean with no windows titlebar, use the no_titlebar option when creating the window.
Be sure an provide your user an "exit" button or they will not be able to close the window! When no titlebar is enabled, there will be no icon on your taskbar for the window. Without an exit button you will need to kill via taskmanager... not fun.
Windows with no titlebar rely on the grab anywhere option to be enabled or else you will be unable to move the window.
Windows without a titlebar can be used to easily create a floating launcher.
![floating launcher](https://user-images.githubusercontent.com/13696193/45258246-71bafb80-b382-11e8-9f5e-79421e6c00bb.jpg)
#### Grab Anywhere
This is a feature unique to PySimpleGUI. The default is ENABLED.... unless the form is a non-blocking form.
It is turned off for non-blocking because there is a warning message printed out if the user closes a non-blocking form using a button with grab_anywhere enabled. There is no harm in these messages, but it may be distressing to the user. Should you wish to enable for a non-blocking form, simply get grab_anywhere = True when you create the form.
#### Always on top
To keep a window on top of all other windows on the screen, set keep_on_top = True when the form is created. This feature makes for floating toolbars that are very helpful and always visible on your desktop.
## Elements