diff --git a/Demo_Script_Launcher.py b/Demo_Script_Launcher.py new file mode 100644 index 00000000..bcc06b00 --- /dev/null +++ b/Demo_Script_Launcher.py @@ -0,0 +1,36 @@ +import PySimpleGUI as sg +import os + +def Launcher(): + + form = sg.FlexForm('Script launcher') + + layout = [ + [sg.Text('Script output....', size=(40, 1))], + [sg.Output(size=(88, 20))], + [sg.ReadFormButton('script1'), sg.ReadFormButton('script2'), sg.SimpleButton('EXIT')] + ] + + form.Layout(layout) + + # ---===--- Loop taking in user input and using it to query HowDoI --- # + while True: + (button, value) = form.Read() + if button == 'EXIT' or button is None: + break # exit button clicked + if button == 'script1': + ExecuteCommandOS('python SimScript.py') + elif button == 'script2': + ExecuteCommandOS('python SimScript.py') + elif button == 'Enter': + ExecuteCommandOS(value[0]) # send string without carriage return on end + + +def ExecuteCommandOS(command): + output = os.popen(command).read() + print(output) + + +if __name__ == '__main__': + Launcher() + diff --git a/SimScript_.py b/SimScript_.py new file mode 100644 index 00000000..2185935b --- /dev/null +++ b/SimScript_.py @@ -0,0 +1,4 @@ +import time + +for i in range(100): + print(i,'', end='')