Jay .
Jay .

Reputation: 21

Run my program inside Tkinter program

Is it possible to run my program inside Tkinter?

I have a program which fits the curves. I want to make it GUI and looking for the ways to insert it into Tkinter.

I want my program to run after clicking a BUTTON widget. Is there a option in Tkinter to run another file.py?

Upvotes: 2

Views: 2555

Answers (2)

aquavitae
aquavitae

Reputation: 19114

I assume you have read the tutorial. The cleanest way of loading the code from another python file is to import it, for example:

import myfile

...
mybutton['command'] = myfile.main
...

Upvotes: 2

Dakeyras
Dakeyras

Reputation: 2251

To run another file, you can import it, or load the data with

file = open("filename.txt", "r")

then use

exec(string)

to run the program inside it.

Upvotes: 0

Related Questions