Refresh of Demo applications

This commit is contained in:
MikeTheWatchGuy 2018-08-09 13:18:04 -04:00
parent 7e1ff1d543
commit 8f220a7ac1
9 changed files with 139 additions and 87 deletions

View File

@ -1,7 +1,7 @@
import PySimpleGUI as sg import PySimpleGUI as sg
def GetFilesToCompare(): def GetFilesToCompare():
with sg.FlexForm('File Compare', auto_size_text=True) as form: with sg.FlexForm('File Compare') as form:
form_rows = [[sg.Text('Enter 2 files to comare')], form_rows = [[sg.Text('Enter 2 files to comare')],
[sg.Text('File 1', size=(15, 1)), sg.InputText(), sg.FileBrowse()], [sg.Text('File 1', size=(15, 1)), sg.InputText(), sg.FileBrowse()],
[sg.Text('File 2', size=(15, 1)), sg.InputText(), sg.FileBrowse()], [sg.Text('File 2', size=(15, 1)), sg.InputText(), sg.FileBrowse()],

View File

@ -9,33 +9,33 @@ def main():
#===== Show some nice BLUE colors with yellow text ===== ===== ===== ===== ===== ===== =====# #===== Show some nice BLUE colors with yellow text ===== ===== ===== ===== ===== ===== =====#
text_color = gg.YELLOWS[0] text_color = gg.YELLOWS[0]
buttons = (gg.SimpleButton(f'BLUES[{j}]\n{c}', button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.BLUES)) buttons = (gg.SimpleButton('BLUES[{}]\n{}'.format(j, c), button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.BLUES))
form.AddRow(gg.T('Button Colors Using PySimpleGUI.BLUES')) form.AddRow(gg.T('Button Colors Using PySimpleGUI.BLUES'))
form.AddRow(*buttons) form.AddRow(*buttons)
form.AddRow(gg.Text('_' * 100, size=(65, 1))) form.AddRow(gg.Text('_' * 100, size=(65, 1)))
#===== Show some nice PURPLE colors with yellow text ===== ===== ===== ===== ===== ===== =====# #===== Show some nice PURPLE colors with yellow text ===== ===== ===== ===== ===== ===== =====#
buttons = (gg.SimpleButton(f'PURPLES[{j}]\n{c}', button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.PURPLES)) buttons = (gg.SimpleButton('PURPLES[{}]\n{}'.format(j, c), button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.PURPLES))
form.AddRow(gg.T('Button Colors Using PySimpleGUI.PURPLES')) form.AddRow(gg.T('Button Colors Using PySimpleGUI.PURPLES'))
form.AddRow(*buttons) form.AddRow(*buttons)
form.AddRow(gg.Text('_' * 100, size=(65, 1))) form.AddRow(gg.Text('_' * 100, size=(65, 1)))
#===== Show some nice GREEN colors with yellow text ===== ===== ===== ===== ===== ===== =====# #===== Show some nice GREEN colors with yellow text ===== ===== ===== ===== ===== ===== =====#
buttons = (gg.SimpleButton(f'GREENS[{j}]\n{c}', button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.GREENS)) buttons = (gg.SimpleButton('GREENS[{}]\n{}'.format(j, c), button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.GREENS))
form.AddRow(gg.T('Button Colors Using PySimpleGUI.GREENS')) form.AddRow(gg.T('Button Colors Using PySimpleGUI.GREENS'))
form.AddRow(*buttons) form.AddRow(*buttons)
form.AddRow(gg.Text('_' * 100, size=(65, 1))) form.AddRow(gg.Text('_' * 100, size=(65, 1)))
#===== Show some nice TAN colors with yellow text ===== ===== ===== ===== ===== ===== =====# #===== Show some nice TAN colors with yellow text ===== ===== ===== ===== ===== ===== =====#
text_color = gg.GREENS[0] # let's use GREEN text on the tan text_color = gg.GREENS[0] # let's use GREEN text on the tan
buttons = (gg.SimpleButton(f'TANS[{j}]\n{c}', button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.TANS)) buttons = (gg.SimpleButton('TANS[{}]\n{}'.format(j, c), button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.TANS))
form.AddRow(gg.T('Button Colors Using PySimpleGUI.TANS')) form.AddRow(gg.T('Button Colors Using PySimpleGUI.TANS'))
form.AddRow(*buttons) form.AddRow(*buttons)
form.AddRow(gg.Text('_' * 100, size=(65, 1))) form.AddRow(gg.Text('_' * 100, size=(65, 1)))
#===== Show some nice YELLOWS colors with black text ===== ===== ===== ===== ===== ===== =====# #===== Show some nice YELLOWS colors with black text ===== ===== ===== ===== ===== ===== =====#
text_color = 'black' # let's use black text on the tan text_color = 'black' # let's use black text on the tan
buttons = (gg.SimpleButton(f'YELLOWS[{j}]\n{c}', button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.YELLOWS)) buttons = (gg.SimpleButton('YELLOWS[{}]\n{}'.format(j, c), button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.YELLOWS))
form.AddRow(gg.T('Button Colors Using PySimpleGUI.YELLOWS')) form.AddRow(gg.T('Button Colors Using PySimpleGUI.YELLOWS'))
form.AddRow(*buttons) form.AddRow(*buttons)
form.AddRow(gg.Text('_' * 100, size=(65, 1))) form.AddRow(gg.Text('_' * 100, size=(65, 1)))

View File

@ -1,9 +1,9 @@
import PySimpleGUI as SG import PySimpleGUI as sg
import subprocess import subprocess
import howdoi import howdoi
# Test this command in a dos window if you are having trouble. # Test this command in a dos window if you are having trouble.
HOW_DO_I_COMMAND = 'python -m howdoi.howdoi' HOW_DO_I_COMMAND = 'python -m howdoi.howdoi -n 2'
# if you want an icon on your taskbar for this gui, then change this line of code to point to the ICO file # if you want an icon on your taskbar for this gui, then change this line of code to point to the ICO file
DEFAULT_ICON = 'E:\\TheRealMyDocs\\Icons\\QuestionMark.ico' DEFAULT_ICON = 'E:\\TheRealMyDocs\\Icons\\QuestionMark.ico'
@ -18,25 +18,29 @@ def HowDoI():
''' '''
# ------- Make a new FlexForm ------- # # ------- Make a new FlexForm ------- #
# Set system-wide options that will affect all future forms. Give our form a spiffy look and feel # Set system-wide options that will affect all future forms. Give our form a spiffy look and feel
SG.SetOptions(background_color='#9FB8AD', text_element_background_color='#9FB8AD', element_background_color='#9FB8AD', scrollbar_color=None, input_elements_background_color='#F7F3EC', button_color=('white','#475841')) sg.SetOptions(background_color='#9FB8AD', text_element_background_color='#9FB8AD', element_background_color='#9FB8AD', scrollbar_color=None, input_elements_background_color='#F7F3EC', button_color=('white', '#475841'))
form = SG.FlexForm('How Do I ??', auto_size_text=True, default_element_size=(30, 2), icon=DEFAULT_ICON) form = sg.FlexForm('How Do I ??', auto_size_text=True, default_element_size=(30, 2), icon=DEFAULT_ICON)
form.AddRow(SG.Text('Ask and your answer will appear here....', size=(40, 1))) layout = [
form.AddRow(SG.Output(size=(90, 20))) [sg.Text('Ask and your answer will appear here....', size=(40, 1))],
form.AddRow(SG.Multiline(size=(85, 5), enter_submits=True), [sg.Output(size=(88, 20))],
SG.ReadFormButton('SEND', button_color=(SG.YELLOWS[0], SG.BLUES[0])), [ sg.Spin(values=(1, 2, 3, 4), initial_value=1, size=(2, 1), key='Num Answers'), sg.T('Num Answers'), sg.Checkbox('Display Full Text', key='full text')],
SG.SimpleButton('EXIT', button_color=(SG.YELLOWS[0], SG.GREENS[0]))) [sg.Multiline(size=(85, 5), enter_submits=True, key='query'),
sg.ReadFormButton('SEND', button_color=(sg.YELLOWS[0], sg.BLUES[0]), bind_return_key=True),
sg.SimpleButton('EXIT', button_color=(sg.YELLOWS[0], sg.GREENS[0]))]
]
form.Layout(layout)
# ---===--- Loop taking in user input and using it to query HowDoI --- # # ---===--- Loop taking in user input and using it to query HowDoI --- #
while True: while True:
(button, value) = form.Read() (button, value) = form.Read()
if button == 'SEND': if button == 'SEND':
QueryHowDoI(value[0][:-1]) # send string without carriage return on end QueryHowDoI(value['query'], value['Num Answers'], value['full text']) # send string without carriage return on end
else: else:
break # exit button clicked break # exit button clicked
exit(69) exit(69)
def QueryHowDoI(Query): def QueryHowDoI(Query, num_answers, full_text):
''' '''
Kicks off a subprocess to send the 'Query' to HowDoI Kicks off a subprocess to send the 'Query' to HowDoI
Prints the result, which in this program will route to a gooeyGUI window Prints the result, which in this program will route to a gooeyGUI window
@ -44,7 +48,8 @@ def QueryHowDoI(Query):
:return: nothing :return: nothing
''' '''
howdoi_command = HOW_DO_I_COMMAND howdoi_command = HOW_DO_I_COMMAND
t = subprocess.Popen(howdoi_command + ' '+ Query, stdout=subprocess.PIPE) full_text_option = ' -a' if full_text else ''
t = subprocess.Popen(howdoi_command + ' '+ Query + ' -n ' + str(num_answers)+full_text_option, stdout=subprocess.PIPE)
(output, err) = t.communicate() (output, err) = t.communicate()
print('You asked: '+ Query) print('You asked: '+ Query)
print('_______________________________________') print('_______________________________________')

50
Demo_Machine_Learning.py Normal file
View File

@ -0,0 +1,50 @@
import PySimpleGUI as sg
def MachineLearningGUI():
sg.SetOptions(text_justification='right')
form = sg.FlexForm('Machine Learning Front End', font=("Helvetica", 12)) # begin with a blank form
layout = [[sg.Text('Machine Learning Command Line Parameters', font=('Helvetica', 16))],
[sg.Text('Passes', size=(15, 1)), sg.Spin(values=[i for i in range(1, 1000)], initial_value=20, size=(6, 1)),
sg.Text('Steps', size=(18, 1)), sg.Spin(values=[i for i in range(1, 1000)], initial_value=20, size=(6, 1))],
[sg.Text('ooa', size=(15, 1)), sg.In(default_text='6', size=(10, 1)), sg.Text('nn', size=(15, 1)), sg.In(default_text='10', size=(10, 1))],
[sg.Text('q', size=(15, 1)), sg.In(default_text='ff', size=(10, 1)), sg.Text('ngram', size=(15, 1)), sg.In(default_text='5', size=(10, 1))],
[sg.Text('l', size=(15, 1)), sg.In(default_text='0.4', size=(10, 1)), sg.Text('Layers', size=(15, 1)), sg.Drop(values=('BatchNorm', 'other'),auto_size_text=True)],
[sg.Text('_' * 100, size=(65, 1))],
[sg.Text('Flags', font=('Helvetica', 15), justification='left')],
[sg.Checkbox('Normalize', size=(12, 1), default=True), sg.Checkbox('Verbose', size=(20, 1))],
[sg.Checkbox('Cluster', size=(12, 1)), sg.Checkbox('Flush Output', size=(20, 1), default=True)],
[sg.Checkbox('Write Results', size=(12, 1)), sg.Checkbox('Keep Intermediate Data', size=(20, 1))],
[sg.Text('_' * 100, size=(65, 1))],
[sg.Text('Loss Functions', font=('Helvetica', 15), justification='left')],
[sg.Radio('Cross-Entropy', 'loss', size=(12, 1)), sg.Radio('Logistic', 'loss', default=True, size=(12, 1))],
[sg.Radio('Hinge', 'loss', size=(12, 1)), sg.Radio('Huber', 'loss', size=(12, 1))],
[sg.Radio('Kullerback', 'loss', size=(12, 1)), sg.Radio('MAE(L1)', 'loss', size=(12, 1))],
[sg.Radio('MSE(L2)', 'loss', size=(12, 1)), sg.Radio('MB(L0)', 'loss', size=(12, 1))],
[sg.Submit(), sg.Cancel()]]
button, values = form.LayoutAndRead(layout)
del(form)
sg.SetOptions(text_justification='left')
return button, values
def CustomMeter():
progress_bar = sg.ProgressBar(10000, orientation='h', size=(20,20))
layout = [[sg.Text('A custom progress meter')],
[progress_bar],
[sg.Cancel()]]
form = sg.FlexForm('Custom Progress Meter')
form.LayoutAndRead(layout, non_blocking=True)
for i in range(10000):
button, values = form.ReadNonBlocking()
progress_bar.UpdateBar(i)
if __name__ == '__main__':
CustomMeter()
MachineLearningGUI()

View File

@ -7,7 +7,9 @@ import PySimpleGUI as sg
# https://user-images.githubusercontent.com/13696193/43159403-45c9726e-8f50-11e8-9da0-0d272e20c579.jpg # https://user-images.githubusercontent.com/13696193/43159403-45c9726e-8f50-11e8-9da0-0d272e20c579.jpg
# #
def MediaPlayerGUI(): def MediaPlayerGUI():
background = '#F0F0F0'
# Set the backgrounds the same as the background on the buttons
sg.SetOptions(background_color=background, element_background_color=background)
# Images are located in a subfolder in the Demo Media Player.py folder # Images are located in a subfolder in the Demo Media Player.py folder
image_pause = './ButtonGraphics/Pause.png' image_pause = './ButtonGraphics/Pause.png'
image_restart = './ButtonGraphics/Restart.png' image_restart = './ButtonGraphics/Restart.png'
@ -22,18 +24,18 @@ def MediaPlayerGUI():
font=("Helvetica", 25)) font=("Helvetica", 25))
# define layout of the rows # define layout of the rows
layout= [[sg.Text('Media File Player',size=(17,1), font=("Helvetica", 25))], layout= [[sg.Text('Media File Player',size=(17,1), font=("Helvetica", 25))],
[TextElem], [TextElem],
[sg.ReadFormButton('Restart Song', button_color=sg.TRANSPARENT_BUTTON, [sg.ReadFormButton('Restart Song', button_color=(background,background),
image_filename=image_restart, image_size=(50, 50), image_subsample=2, border_width=0), image_filename=image_restart, image_size=(50, 50), image_subsample=2, border_width=0),
sg.Text(' ' * 2), sg.Text(' ' * 2),
sg.ReadFormButton('Pause', button_color=sg.TRANSPARENT_BUTTON, sg.ReadFormButton('Pause', button_color=(background,background),
image_filename=image_pause, image_size=(50, 50), image_subsample=2, border_width=0), image_filename=image_pause, image_size=(50, 50), image_subsample=2, border_width=0),
sg.Text(' ' * 2), sg.Text(' ' * 2),
sg.ReadFormButton('Next', button_color=sg.TRANSPARENT_BUTTON, sg.ReadFormButton('Next', button_color=(background,background),
image_filename=image_next, image_size=(50, 50), image_subsample=2, border_width=0), image_filename=image_next, image_size=(50, 50), image_subsample=2, border_width=0),
sg.Text(' ' * 2), sg.Text(' ' * 2),
sg.Text(' ' * 2), sg.SimpleButton('Exit', button_color=sg.TRANSPARENT_BUTTON, sg.Text(' ' * 2), sg.SimpleButton('Exit', button_color=(background,background),
image_filename=image_exit, image_size=(50, 50), image_subsample=2, border_width=0)], image_filename=image_exit, image_size=(50, 50), image_subsample=2, border_width=0)],
[sg.Text('_'*30)], [sg.Text('_'*30)],
[sg.Text(' '*30)], [sg.Text(' '*30)],
[ [

View File

@ -44,18 +44,14 @@ def StatusOutputExample():
def RemoteControlExample(): def RemoteControlExample():
# Make a form, but don't use context manager # Make a form, but don't use context manager
form = sg.FlexForm('Running Timer', auto_size_text=True) form = sg.FlexForm('Robotics Remote Control', auto_size_text=True)
# Create a text element that will be updated with status information on the GUI itself
output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20), justification='center')
form_rows = [[sg.Text('Robotics Remote Control')], form_rows = [[sg.Text('Robotics Remote Control')],
[output_element],
[sg.T(' '*10), sg.RealtimeButton('Forward')], [sg.T(' '*10), sg.RealtimeButton('Forward')],
[ sg.RealtimeButton('Left'), sg.T(' '*15), sg.RealtimeButton('Right')], [ sg.RealtimeButton('Left'), sg.T(' '*15), sg.RealtimeButton('Right')],
[sg.T(' '*10), sg.RealtimeButton('Reverse')], [sg.T(' '*10), sg.RealtimeButton('Reverse')],
[sg.T('')], [sg.T('')],
[sg.Quit()] [sg.Quit(button_color=('black', 'orange'))]
] ]
form.LayoutAndRead(form_rows, non_blocking=True) form.LayoutAndRead(form_rows, non_blocking=True)
@ -66,25 +62,15 @@ def RemoteControlExample():
# else it won't refresh. # else it won't refresh.
# #
# your program's main loop # your program's main loop
i=0
while (True): while (True):
# This is the code that reads and updates your window # This is the code that reads and updates your window
output_element.Update('{:02d}:{:02d}.{:02d}'.format((i // 100) // 60, (i // 100) % 60, i % 100))
button, values = form.ReadNonBlocking() button, values = form.ReadNonBlocking()
if button is not None: if button is not None:
print(button) sg.Print(button)
if button == 'Quit' or values is None: if button == 'Quit' or values is None:
break break
if button == 'LED On': # time.sleep(.01)
print('Turning on the LED')
elif button == 'LED Off':
print('Turning off the LED')
i += 1
# Your code begins here
time.sleep(.01)
# Broke out of main loop. Close the window.
form.CloseNonBlockingForm() form.CloseNonBlockingForm()

View File

@ -88,7 +88,7 @@ def RemoteControlExample_NoGraphics():
def main(): def main():
RemoteControlExample_NoGraphics() RemoteControlExample_NoGraphics()
# Uncomment to get the fancy graphics version. Be sure and download the button images! # Uncomment to get the fancy graphics version. Be sure and download the button images!
# RemoteControlExample() RemoteControlExample()
sg.MsgBox('End of non-blocking demonstration') sg.MsgBox('End of non-blocking demonstration')
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -5,10 +5,10 @@ import PySimpleGUI as sg
# A simple blocking form. Your best starter-form # A simple blocking form. Your best starter-form
def SourceDestFolders(): def SourceDestFolders():
with sg.FlexForm('Demo Source / Destination Folders') as form: with sg.FlexForm('Demo Source / Destination Folders') as form:
form_rows = [[sg.Text('Enter the Source and Destination folders')], form_rows = ([sg.Text('Enter the Source and Destination folders')],
[sg.Text('Source Folder', size=(15, 1), justification='right'), sg.InputText('Source'), sg.FolderBrowse()], [sg.Text('Source Folder', size=(15, 1), justification='right'), sg.InputText('Source'), sg.FolderBrowse()],
[sg.Text('Destination Folder', size=(15, 1), justification='right'), sg.InputText('Dest'), sg.FolderBrowse()], [sg.Text('Destination Folder', size=(15, 1), justification='right'), sg.InputText('Dest'), sg.FolderBrowse()],
[sg.Submit(), sg.Cancel()]] [sg.Submit(), sg.Cancel()])
button, (source, dest) = form.LayoutAndRead(form_rows) button, (source, dest) = form.LayoutAndRead(form_rows)
if button == 'Submit': if button == 'Submit':
@ -39,7 +39,7 @@ def MachineLearningGUI():
[sg.Radio('Kullerback', 'loss', size=(12, 1)), sg.Radio('MAE(L1)', 'loss', size=(12, 1))], [sg.Radio('Kullerback', 'loss', size=(12, 1)), sg.Radio('MAE(L1)', 'loss', size=(12, 1))],
[sg.Radio('MSE(L2)', 'loss', size=(12, 1)), sg.Radio('MB(L0)', 'loss', size=(12, 1))], [sg.Radio('MSE(L2)', 'loss', size=(12, 1)), sg.Radio('MB(L0)', 'loss', size=(12, 1))],
[sg.Submit(), sg.Cancel()]] [sg.Submit(), sg.Cancel()]]
button, values = form.LayoutAndShow(layout) button, values = form.LayoutAndRead(layout)
del(form) del(form)
sg.SetOptions(text_justification='left') sg.SetOptions(text_justification='left')
@ -70,10 +70,8 @@ def Everything():
sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=10), sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=10),
sg.Spin(values=('Spin Box 1', '2','3'), initial_value='Spin Box 1')], sg.Spin(values=('Spin Box 1', '2','3'), initial_value='Spin Box 1')],
[sg.Text('_' * 80)], [sg.Text('_' * 80)],
[sg.Text('Choose A Folder', size=(35, 1))],
[sg.Text('Your Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Default Folder'), sg.FolderBrowse()], [sg.Text('Your Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Default Folder'), sg.FolderBrowse()],
[sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('black', '#EDE5B7'))] [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('black', '#EDE5B7'))] ]
]
button, values = form.LayoutAndRead(layout) button, values = form.LayoutAndRead(layout)
@ -113,8 +111,8 @@ def Everything_NoContextManager():
def ProgressMeter(): def ProgressMeter():
for i in range(1,100): for i in range(1,1000):
if not sg.EasyProgressMeter('My Meter', i + 1, 100, orientation='v'): break if not sg.EasyProgressMeter('My Meter', i + 1, 1000, orientation='h'): break
time.sleep(.01) time.sleep(.01)
# Blocking form that doesn't close # Blocking form that doesn't close
@ -122,7 +120,7 @@ def ChatBot():
with sg.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: with sg.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form:
layout = [[(sg.Text('This is where standard out is being routed', size=[40, 1]))], layout = [[(sg.Text('This is where standard out is being routed', size=[40, 1]))],
[sg.Output(size=(80, 20))], [sg.Output(size=(80, 20))],
[sg.Multiline(size=(70, 5), enter_submits=True), sg.ReadFormButton('SEND', button_color=(sg.YELLOWS[0], sg.BLUES[0])), sg.SimpleButton('EXIT', button_color=(sg.YELLOWS[0], sg.GREENS[0]))]] [sg.Multiline(size=(70, 5), enter_submits=True), sg.ReadFormButton('SEND', button_color=(sg.YELLOWS[0], sg.BLUES[0]), bind_return_key=True), sg.SimpleButton('EXIT', button_color=(sg.YELLOWS[0], sg.GREENS[0]))]]
# notice this is NOT the usual LayoutAndRead call because you don't yet want to read the form # notice this is NOT the usual LayoutAndRead call because you don't yet want to read the form
# if you call LayoutAndRead from here, then you will miss the first button click # if you call LayoutAndRead from here, then you will miss the first button click
form.Layout(layout) form.Layout(layout)
@ -181,39 +179,46 @@ def NonBlockingPeriodicUpdateForm():
def DebugTest(): def DebugTest():
# SG.Print('How about we print a bunch of random numbers?', , size=(90,40)) # SG.Print('How about we print a bunch of random numbers?', , size=(90,40))
for i in range (1,300): for i in range (1,300):
sg.Print(i, randint(1, 1000), end='', sep='-') sg.Print('Here are 300 random numbers', i, randint(1, 1000), sep='-')
# Change the colors and set borders to 0 for a flat look
def ChangeLookAndFeel(colors):
sg.SetOptions(background_color=colors['BACKGROUND'],
text_element_background_color=colors['BACKGROUND'],
element_background_color=colors['BACKGROUND'],
text_color=colors['TEXT'],
input_elements_background_color=colors['INPUT'],
button_color=colors['BUTTON'],
progress_meter_color=colors['PROGRESS'],
border_width=0,
slider_border_width=0,
progress_meter_border_depth=0,
scrollbar_color=(colors['INPUT']),
element_text_color=colors['TEXT'])
#=---------------------------------- main ------------------------------ #=---------------------------------- main ------------------------------
def main(): def main():
# sg.MsgBox('Changing look and feel.', 'Done by calling SetOptions') # Green & tan color scheme
SourceDestFolders() colors1 = {'BACKGROUND' : '#9FB8AD', 'TEXT': sg.COLOR_SYSTEM_DEFAULT, 'INPUT':'#F7F3EC', 'BUTTON': ('white', '#475841'),'PROGRESS':sg.DEFAULT_PROGRESS_BAR_COLOR }
# light green with tan
sg.SetOptions(background_color='#9FB8AD', text_element_background_color='#9FB8AD', element_background_color='#9FB8AD', scrollbar_color=None, input_elements_background_color='#F7F3EC', button_color=('white','#475841'), border_width=0, slider_border_width=0, progress_meter_border_depth=0) colors2 = {'BACKGROUND' : '#B7CECE', 'TEXT': 'black', 'INPUT':'#FDFFF7', 'BUTTON': ('white', '#658268'), 'PROGRESS':('#247BA0','#F8FAF0')}
# blue with light blue color scheme
MachineLearningGUI() colors3 = {'BACKGROUND' : '#A5CADD', 'TEXT': '#6E266E', 'INPUT':'#E0F5FF', 'BUTTON': ('white', '#303952'),'PROGRESS':sg.DEFAULT_PROGRESS_BAR_COLOR}
Everything_NoContextManager()
# sg.SetOptions(background_color='#B89FB6', text_element_background_color='#B89FB6', element_background_color='#B89FB6', button_color=('white','#7E6C92'), text_color='#3F403F',border_width=0, slider_border_width=0, progress_meter_border_depth=0)
sg.SetOptions(background_color='#A5CADD', input_elements_background_color='#E0F5FF', text_element_background_color='#A5CADD', element_background_color='#A5CADD', button_color=('white','#303952'), text_color='#822E45',border_width=0, progress_meter_color=('#3D8255','white'), slider_border_width=0, progress_meter_border_depth=0)
Everything()
ProgressMeter()
# Set system-wide options that will affect all future forms
NonBlockingPeriodicUpdateForm_ContextManager()
NonBlockingPeriodicUpdateForm()
ChatBot() ChatBot()
Everything()
SourceDestFolders()
ChangeLookAndFeel(colors2)
ProgressMeter()
ChangeLookAndFeel(colors3)
Everything()
ChangeLookAndFeel(colors2)
MachineLearningGUI()
Everything_NoContextManager()
NonBlockingPeriodicUpdateForm_ContextManager()
NonBlockingPeriodicUpdateForm()
DebugTest() DebugTest()
sg.MsgBox('Done with all recipes') sg.MsgBox('Done with all recipes')

View File

@ -2,12 +2,16 @@ import PySimpleGUI as sg
form = sg.FlexForm('Simple data entry form') # begin with a blank form form = sg.FlexForm('Simple data entry form') # begin with a blank form
layout = [[sg.Text('Please enter your Name, Address, Phone')], layout = [
[sg.Text('Name', size=(15, 1)), sg.InputText()], [sg.Text('Please enter your Name, Address, Phone')],
[sg.Text('Address', size=(15, 1)), sg.InputText()], [sg.Text('Name', size=(15, 1)), sg.InputText('1', key='name')],
[sg.Text('Phone', size=(15, 1)), sg.InputText()], [sg.Text('Address', size=(15, 1)), sg.InputText('2', key='address')],
[sg.Submit(), sg.Cancel()]] [sg.Text('Phone', size=(15, 1)), sg.InputText('3', key='phone')],
[sg.Submit(), sg.Cancel()]
]
button, (name, address, phone) = form.LayoutAndRead(layout) button, values = form.LayoutAndRead(layout)
print(name, address, phone) sg.MsgBox(button, values['name'], values['address'], values['phone'])
print(values)