I am trying to run a .py file from another python code using the following sequence.
from tkinter import *
import os
import sys
def open_SS():
print('processing')
os.system('cd /home/pi/Desktop/Backup')
os.system('python p.py')
def close_window():
master.destroy()
master = Tk()
master.minsize(width=500, height=300)
Button(master, text='Exit', command=close_window).grid(row=12, column=6, sticky=W, pady=4)
Button(master, text='SS', command=open_SS).grid(row=12, column=8, sticky=W, pady=4)
mainloop( )
The Exit button does the command, but the 'SS' button does not, the word 'processing' does get printed, just the running of the p.py file. I tried running those two os.system commands on a command terminal and it works fine. p.py is supposed to input GPIO signals to a Raspberry Pi.
import p?cd ...andpython ...need to be in the sameos.systeminvocation, for exampleos.system('cd ...; python ...'). If you separate them, they are executed in separate shells, and thecdperformed in the firstos.system()does not affect the second one.