Merge pull request #169 from MikeTheWatchGuy/Dev-latest

Dev latest
This commit is contained in:
MikeTheWatchGuy 2018-09-08 15:16:20 -04:00 committed by GitHub
commit 490673bbab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 12 deletions

View File

@ -274,7 +274,7 @@ def RealtimeButtons():
import PySimpleGUI as sg import PySimpleGUI as sg
# Make a form, but don't use context manager # Make a form, but don't use context manager
form = sg.FlexForm('Robotics Remote Control', auto_size_text=True, grab_anywhere=False) form = sg.FlexForm('Robotics Remote Control', auto_size_text=True)
form_rows = [[sg.Text('Robotics Remote Control')], form_rows = [[sg.Text('Robotics Remote Control')],
[sg.T(' ' * 10), sg.RealtimeButton('Forward')], [sg.T(' ' * 10), sg.RealtimeButton('Forward')],
@ -759,21 +759,23 @@ while True:
# sg.ChangeLookAndFeel('Dark') # sg.ChangeLookAndFeel('Dark')
# sg.SetOptions(element_padding=(0,0)) # sg.SetOptions(element_padding=(0,0))
col_listbox = [[sg.Listbox(values=listbox_values, size=(max(len(x) for x in listbox_values),len(listbox_values)), change_submits=True, key='func')], col_listbox = [[sg.Listbox(values=listbox_values, size=(max(len(x) for x in listbox_values),min(len(listbox_values), 20)), change_submits=False, key='func')],
[sg.SimpleButton('Run', pad=((30,0),0)), sg.Exit(button_color=('white', 'firebrick4'))]] [sg.ReadFormButton('Run', pad=(0,0)), sg.ReadFormButton('Show Code', button_color=('white', 'gray25'), pad=(0,0)), sg.Exit(button_color=('white', 'firebrick4'), pad=(0,0))]]
layout = [[sg.Text('PySimpleGUI Coookbook', font=('current 18'))], layout = [[sg.Text('PySimpleGUI Coookbook', font=('current 18'))],
[sg.Column(col_listbox), sg.Multiline(size=(70,35), do_not_clear=True, key='multi')], [sg.Column(col_listbox), sg.Multiline(size=(50,min(len(listbox_values), 20)), do_not_clear=True, key='multi')],
] ]
# create the form and show it without the plot # create the form and show it without the plot
# form.Layout(layout) # form.Layout(layout)
form = sg.FlexForm('Demo Application - Embedding Matplotlib In PySimpleGUI', default_button_element_size=(10,1),auto_size_buttons=False, no_titlebar=True) form = sg.FlexForm('Demo Application - Embedding Matplotlib In PySimpleGUI', default_button_element_size=(9,1),auto_size_buttons=False, grab_anywhere=False)
button, values = form.LayoutAndRead(layout) form.Layout(layout)
# show it all again and get buttons # show it all again and get buttons
while True: while True:
if button is None or button is 'Exit': button, values = form.Read()
if button is None or button == 'Exit':
exit(69) exit(69)
try: try:
choice = values['func'][0] choice = values['func'][0]
@ -781,12 +783,14 @@ while True:
except: except:
continue continue
if button is '': if button == 'Show Code' and values['multi']:
form.FindElement('multi').Update(inspect.getsource(func)) form.FindElement('multi').Update(inspect.getsource(func))
button, values = form.Read() elif button is 'Run' and values['func']:
elif button is 'Run':
# sg.ChangeLookAndFeel('SystemDefault') # sg.ChangeLookAndFeel('SystemDefault')
form.CloseNonBlockingForm()
func() func()
break break
else: else:
button, values = form.Read() print('ILLEGAL values')
break

View File

@ -231,7 +231,6 @@ class Element():
self.ParentForm.FormRemainedOpen = True self.ParentForm.FormRemainedOpen = True
self.ParentForm.TKroot.quit() # kick the users out of the mainloop self.ParentForm.TKroot.quit() # kick the users out of the mainloop
def ComboboxSelectHandler(self, event): def ComboboxSelectHandler(self, event):
MyForm = self.ParentForm MyForm = self.ParentForm
# first, get the results table built # first, get the results table built