-1

I'm a beginner in Python, hence the question. i would like to run a python file (smileA.py) in Tkinter. How would i start?

I do not wish for it to run when clicking a button, but the file to run automatically in the Tkinter itself.

Thanks.

3
  • 1
    I don't understand your question. Does your file smileA.py use tkinter? How do you run your Python files? Commented Sep 14, 2015 at 8:46
  • I run my python in the files itself.. smileA.py when run will be opened as a windows program. is it possible to instead open/display it in Tk? Commented Sep 15, 2015 at 1:38
  • Does your file smileA.py use tkinter? Commented Sep 15, 2015 at 7:15

1 Answer 1

0

What you need a module called subprocess, which will allow you to run files, from within your python code, by using Popen.

The code for running the file will look something like this, once you import the module:

from subprocess import Popen

p = Popen("smileA.py")
stdout, stderr = p.communicate()

If that's what you mean by "Running it in Tkinter", as in, running that code, while building a GUI in Tkinter in the same file.

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.