I am using tkinter.
I have the following code printing out the console output to GUI in live mode. Now it simple prints the numbers (delay is needed so that I can see that it is in real-life).
import tkinter as tk
import time
import sys
class Display(tk.Frame):
def __init__(self):
tk.Frame.__init__(self)
self.doIt = tk.Button(self,text="Start", command=self.start, background = 'black', fg='white')
self.doIt.pack()
self.output = tk.Text(self, width=100, height=15, background = 'black', fg='white')
self.output.pack()
sys.stdout = self
self.configure(background='black')
self.pack()
def start(self):
for i in range (1, 1000):
print (i)
time.sleep(2)
def write(self, txt):
self.output.insert(tk.END,str(txt))
self.update_idletasks()
if __name__ == '__main__':
Display().mainloop()
However, when I try to fold the window or switch to another application it freezes. Another thing is that I want it to scroll down and show new output as it reaches the end of the window. I would appreciate any help on these issues.