I have two .py files. How can I get multi-lined output of one program into tkinter text of another program's GUI?
<p>GUI consists one Run Button which should run the first program as many times user wants &amp; display output in tkinter text.</p>

<p>My code(2nd .py file):</p>

<pre><code>from tkinter import*
from tkinter import ttk
import Random Game

root = Tk()
root.title("Random Game 1.0")

quote = "Long \nRandom \nText \nGenerated \nBy \nRandom Function \nAnd \nControl Structures"

frame = Frame(root)

labelText = StringVar()

label = Label(frame, textvariable=labelText).pack()
button = Button(frame, text="Click to Run").pack()

labelText.set("Random Game 1.0")
Label(root, text ="")

T = Text(root)

frame.pack()

T.pack()
T.insert(END, quote)

root.mainloop()
</code></pre>

<p>I want Output of 1st program which is random every time in "tkinter text of another (2nd program) instead of quote lines mentioned in above code.</p>

<p>Output first program to txt file.</p>

<p>Read from that txt file into the tkinter GUI by checking when it was last modified so as to avoid mutex issues.</p>

<p>Therefore:</p>

<pre><code># Prog 1:

file = open("log.txt", "w")
# code that writes there

# Prog 2:

file = open("log.txt", "r")
# use data to show in the tkinter with its mainloop for example
# in mainloop()...
#    .....
     if other_prog_has_written_something_new  :
         data = file.readlines()
         useDataInGUI(data)
</code></pre>

python python-2.7 python-3.x user-interface tkinter