can you guys help me to know how to connect a button in my PySimpleGui script which will execute another python script when the run button is pressed/clicked.
For now, i've been reading about Subprocess and command = os.popen in a GUI script.
layout = [[ sg.Text('Click the button to launch Program')],
[sg.Button('Launch')]]
win1 = sg.Window('My new window').Layout(layout)
win2_activate = False
while True:
ev1, vals1 = win1.Read()
if ev1 is None or ev1 == 'Cancel':
break
if not win2_activate and ev1 == 'Launch':
win1.Hide()
win2_activate = True
layout2 = [[sg.Text('Report Auto')],
[sg.Input(do_not_clear=True)],
[sg.Text('', key='_OUTPUT_')],
[sg.Button('Run'), sg.Button('Cancel')]]
win2 = sg.Window('Window2').Layout(layout2)
while True:
ev2, vals2 = win2.Read()
if ev2 is None or ev2 =='Cancel':
win2_activate = False
win2.Close()
win1.UnHide()
break
In my pysimplegui script, i have not yet included the subprocess or any library because i just don't know where to do it. Any help will is most welcome!