0

I am having a Python page named Home.py and it is containing a button named View Reports. When I click this button I want another Python page named Reports.py to get executed. I developed the UI using tkinter.

9
  • You can use subprocess to execute the external script. Or if the main block is inside a function in the external script, import the function and call the function. Commented Mar 19, 2020 at 7:51
  • I have tried the subprocess . But it wont work in my system. Commented Mar 19, 2020 at 7:53
  • 1
    What have you tried with subprocess? Post the test code. Commented Mar 19, 2020 at 7:59
  • command = ("View Reports.py") subprocess.Popen(command, shell=True) Commented Mar 19, 2020 at 8:02
  • Why didn't you use python to execute the Reports.py script? Commented Mar 19, 2020 at 8:05

1 Answer 1

1

Try the below code. Works for me.

def RunWrapper():
    wrapper = ['python', 'Reports.py']
    result1 = subprocess.Popen(wrapper,  stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
    out1, err1 = result1.communicate()
    status_wrapper=out1.decode("utf-8")
    tkinter.messagebox.showinfo("Execution of script is done")

Button.configure(pady="0",text='''Execute''',command=RunWrapper)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.