Is it possible to display the result of any variable in another file to the scrolltext. My question is: Image I have two python files. py1.py is the main file which contains only scrolledtext widget. And what I need to realize is that I want the result of any variable in py2.py to be consciously (incrementally) displayed in the scrolledtext widget (which is embedded in py1.py).
# -*- coding: utf-8 -*-
"""
py1.py
"""
import tkinter as tk
from tkinter import scrolledtext
win = tk.Tk()
text_area = scrolledtext.ScrolledText(win)
# for ii in range(100000):
# mystr = "Step " + str(ii) + "\n"
# text_area.insert(tk.END, mystr)
exec(open("py2.py").read())
text_area.see(tk.END)
text_area.pack()
win.mainloop()
"""
py2.py
"""
import tkinter as tk
from py1 import text_area
for ii in range(100000):
mystr = "Step " + str(ii) + "\n"
text_area.insert(tk.END, mystr)