Various fixes
This commit is contained in:
parent
ceb09ae62c
commit
a968100ab8
|
@ -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)
|
form = sg.FlexForm('Robotics Remote Control', auto_size_text=True, grab_anywhere=False)
|
||||||
|
|
||||||
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')],
|
||||||
|
@ -431,10 +431,9 @@ def ScriptLauncher():
|
||||||
|
|
||||||
def ExecuteCommandSubprocess(command, *args):
|
def ExecuteCommandSubprocess(command, *args):
|
||||||
try:
|
try:
|
||||||
# expanded_args = []
|
expanded_args = []
|
||||||
# for a in args:
|
for a in args:
|
||||||
# expanded_args += a
|
expanded_args += a
|
||||||
expanded_args = [*args]
|
|
||||||
sp = subprocess.Popen([command,expanded_args], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
sp = subprocess.Popen([command,expanded_args], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
out, err = sp.communicate()
|
out, err = sp.communicate()
|
||||||
if out:
|
if out:
|
||||||
|
@ -757,8 +756,8 @@ fig_dict = {'Simple Data Entry':SimpleDataEntry, 'Simple Entry Return Data as Di
|
||||||
listbox_values = [key for key in fig_dict.keys()]
|
listbox_values = [key for key in fig_dict.keys()]
|
||||||
|
|
||||||
while True:
|
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),len(listbox_values)), change_submits=True, key='func')],
|
||||||
[sg.SimpleButton('Run', pad=((30,0),0)), sg.Exit(button_color=('white', 'firebrick4'))]]
|
[sg.SimpleButton('Run', pad=((30,0),0)), sg.Exit(button_color=('white', 'firebrick4'))]]
|
||||||
|
|
|
@ -97,9 +97,9 @@ def StatusOutputExample_context_manager():
|
||||||
form.CloseNonBlockingForm()
|
form.CloseNonBlockingForm()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
StatusOutputExample()
|
|
||||||
RemoteControlExample()
|
RemoteControlExample()
|
||||||
StatusOutputExample()
|
StatusOutputExample()
|
||||||
|
StatusOutputExample()
|
||||||
sg.MsgBox('End of non-blocking demonstration')
|
sg.MsgBox('End of non-blocking demonstration')
|
||||||
# StatusOutputExample_context_manager()
|
# StatusOutputExample_context_manager()
|
||||||
|
|
||||||
|
|
|
@ -8,19 +8,22 @@ import PySimpleGUI as sg
|
||||||
|
|
||||||
def RemoteControlExample():
|
def RemoteControlExample():
|
||||||
# Make a form, but don't use context manager
|
# Make a form, but don't use context manager
|
||||||
|
sg.SetOptions(element_padding=(0,0))
|
||||||
back ='#eeeeee'
|
back ='#eeeeee'
|
||||||
image_forward = 'ButtonGraphics/RobotForward.png'
|
image_forward = 'ButtonGraphics/RobotForward.png'
|
||||||
image_backward = 'ButtonGraphics/RobotBack.png'
|
image_backward = 'ButtonGraphics/RobotBack.png'
|
||||||
image_left = 'ButtonGraphics/RobotLeft.png'
|
image_left = 'ButtonGraphics/RobotLeft.png'
|
||||||
image_right = 'ButtonGraphics/RobotRight.png'
|
image_right = 'ButtonGraphics/RobotRight.png'
|
||||||
|
|
||||||
sg.SetOptions(border_width=0, button_color=('black', back), background_color=back, element_background_color=back, text_element_background_color=back)
|
sg.SetOptions(border_width=0, button_color=('black', back), background_color=back, element_background_color=back, text_element_background_color=back)
|
||||||
|
|
||||||
form = sg.FlexForm('Robotics Remote Control', auto_size_text=True, grab_anywhere=False)
|
form = sg.FlexForm('Robotics Remote Control', auto_size_text=True, grab_anywhere=False)
|
||||||
status_display_elem = sg.T('', justification='center', size=(19,1))
|
|
||||||
form_rows = [[sg.Text('Robotics Remote Control')],
|
form_rows = [[sg.Text('Robotics Remote Control')],
|
||||||
[status_display_elem],
|
[sg.T('', justification='center', size=(19,1), key='status')],
|
||||||
[sg.T(' '*6), sg.RealtimeButton('Forward', image_filename=image_forward)],
|
[ sg.RealtimeButton('Forward', image_filename=image_forward, pad=((50,0),0))],
|
||||||
[ sg.RealtimeButton('Left', image_filename=image_left), sg.T(' '), sg.RealtimeButton('Right', image_filename=image_right)],
|
[ sg.RealtimeButton('Left', image_filename=image_left), sg.RealtimeButton('Right', image_filename=image_right, pad=((50,0), 0))],
|
||||||
[sg.T(' '*6), sg.RealtimeButton('Reverse', image_filename=image_backward)],
|
[ sg.RealtimeButton('Reverse', image_filename=image_backward, pad=((50,0),0))],
|
||||||
[sg.T('')],
|
[sg.T('')],
|
||||||
[sg.Quit(button_color=('black', 'orange'))]
|
[sg.Quit(button_color=('black', 'orange'))]
|
||||||
]
|
]
|
||||||
|
@ -37,9 +40,9 @@ def RemoteControlExample():
|
||||||
# This is the code that reads and updates your window
|
# This is the code that reads and updates your window
|
||||||
button, values = form.ReadNonBlocking()
|
button, values = form.ReadNonBlocking()
|
||||||
if button is not None:
|
if button is not None:
|
||||||
status_display_elem.Update(button)
|
form.FindElement('status').Update(button)
|
||||||
else:
|
else:
|
||||||
status_display_elem.Update('')
|
form.FindElement('status').Update('')
|
||||||
# if user clicked quit button OR closed the form using the X, then break out of loop
|
# if user clicked quit button OR closed the form using the X, then break out of loop
|
||||||
if button == 'Quit' or values is None:
|
if button == 'Quit' or values is None:
|
||||||
break
|
break
|
||||||
|
@ -50,11 +53,11 @@ def RemoteControlExample():
|
||||||
def RemoteControlExample_NoGraphics():
|
def RemoteControlExample_NoGraphics():
|
||||||
# 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, grab_anywhere=False)
|
||||||
status_display_elem = sg.T('', justification='center', size=(19,1))
|
|
||||||
form_rows = [[sg.Text('Robotics Remote Control', justification='center')],
|
form_rows = [[sg.Text('Robotics Remote Control', justification='center')],
|
||||||
[status_display_elem],
|
[sg.T('', justification='center', size=(19,1), key='status')],
|
||||||
[sg.T(' '*8), sg.RealtimeButton('Forward')],
|
[sg.T(' '*8), sg.RealtimeButton('Forward')],
|
||||||
[ sg.RealtimeButton('Left'), sg.T(' '), sg.RealtimeButton('Right')],
|
[ sg.RealtimeButton('Left'), sg.T(' '), sg.RealtimeButton('Right')],
|
||||||
[sg.T(' '*8), sg.RealtimeButton('Reverse')],
|
[sg.T(' '*8), sg.RealtimeButton('Reverse')],
|
||||||
[sg.T('')],
|
[sg.T('')],
|
||||||
[sg.Quit(button_color=('black', 'orange'))]
|
[sg.Quit(button_color=('black', 'orange'))]
|
||||||
|
@ -72,9 +75,9 @@ def RemoteControlExample_NoGraphics():
|
||||||
# This is the code that reads and updates your window
|
# This is the code that reads and updates your window
|
||||||
button, values = form.ReadNonBlocking()
|
button, values = form.ReadNonBlocking()
|
||||||
if button is not None:
|
if button is not None:
|
||||||
status_display_elem.Update(button)
|
form.FindElement('status').Update(button)
|
||||||
else:
|
else:
|
||||||
status_display_elem.Update('')
|
form.FindElement('status').Update('')
|
||||||
# if user clicked quit button OR closed the form using the X, then break out of loop
|
# if user clicked quit button OR closed the form using the X, then break out of loop
|
||||||
if button == 'Quit' or values is None:
|
if button == 'Quit' or values is None:
|
||||||
break
|
break
|
||||||
|
@ -89,7 +92,7 @@ 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.Popup('End of non-blocking demonstration')
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,16 @@ import glob
|
||||||
import ntpath
|
import ntpath
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
LOCATION_OF_YOUR_SCRIPTS = 'C:/Python/PycharmProjects/GooeyGUI/'
|
LOCATION_OF_YOUR_SCRIPTS = ''
|
||||||
|
|
||||||
# Execute the command. Will not see the output from the command until it completes.
|
# Execute the command. Will not see the output from the command until it completes.
|
||||||
def execute_command_blocking(command, *args):
|
def execute_command_blocking(command, *args):
|
||||||
|
expanded_args = []
|
||||||
|
for a in args:
|
||||||
|
expanded_args.append(a)
|
||||||
|
# expanded_args += a
|
||||||
try:
|
try:
|
||||||
sp = subprocess.Popen([command,*args], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
sp = subprocess.Popen([command,expanded_args], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
out, err = sp.communicate()
|
out, err = sp.communicate()
|
||||||
if out:
|
if out:
|
||||||
print(out.decode("utf-8"))
|
print(out.decode("utf-8"))
|
||||||
|
@ -20,8 +24,11 @@ def execute_command_blocking(command, *args):
|
||||||
|
|
||||||
# Executes command and immediately returns. Will not see anything the script outputs
|
# Executes command and immediately returns. Will not see anything the script outputs
|
||||||
def execute_command_nonblocking(command, *args):
|
def execute_command_nonblocking(command, *args):
|
||||||
|
expanded_args = []
|
||||||
|
for a in args:
|
||||||
|
expanded_args += a
|
||||||
try:
|
try:
|
||||||
sp = subprocess.Popen([command,*args], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
sp = subprocess.Popen([command,expanded_args], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
except: pass
|
except: pass
|
||||||
|
|
||||||
def Launcher2():
|
def Launcher2():
|
||||||
|
|
Loading…
Reference in New Issue