-3

I am trying a to build a project using tkinter where I am able to launch a python file(like: text editor) from my main file using buttons. Can anyone help me with that? And yes I tried using command attribute but it only calls function not the whole module.

AVX-42
  • 755
  • 2
  • 13
  • 21
  • Possible duplicate of [How to execute a Python program in Tkinter](https://stackoverflow.com/questions/23253262/how-to-execute-a-python-program-in-tkinter) – AVX-42 Feb 21 '19 at 10:09

1 Answers1

0

So you want to execute a python file from the text editor you made. There is already an answer answer You can write some code like:

exec.py:

#!/usr/bin/python3

def run_on_exec():
    print("Program Run")

if __name__ == "__main__":
    run_on_exec()

main.py:

#!/usr/bin/python3

import tkinter
import os

def run_txt_editor():
    os.system("python exec.py")

#----snip----
btn = tkinter.Button(root, text="run txt editor", command=run_txt_editor)


if __name__ == "__main__":
     root.mainloop()

Maybe this is what you want.

AVX-42
  • 755
  • 2
  • 13
  • 21
  • This is not what I meant I wanted to create OS type of interface using tkinter and when one clicks on the button named text editor a new window will launch which will be text editor designed in tkinter. – Shrawan chakradhar Feb 16 '19 at 13:59