I have trouble entering the output of a function in another scrolledtext class, which I have simplified so that I can better explain.
I have a function in a class (named A) and I want to write it's print content in ScrolledText in another class (B) like below:
import time
class A:
def func(self):
for i in range(0, 4):
print(i)
time.sleep(0.5)
pass
I use this method but I do not get an answer:
from tkinter import *
from tkinter.scrolledtext import ScrolledText
In[1]:class B:
root = Tk()
def finish():
text.insert(INSERT, A().func()) # Here I have tried to write in the ScrolledText
# But it does not work
text = ScrolledText(root)
text.grid(row = 0, column = 0)
button_openfile = Button(root, text = 'Start', command = finish)
button_openfile.grid(row = 1, column = 0)
root.mainloop()
In[2]:if __name__ == "__main__":
B()