Is there a way to redirect all IDLE output to a tkinter GUI, or do something with the IDLE outputs? I want to show all IDLE output from the http.server
module in a tkinter GUI, to monitor all things happening to a webserver. Is this doable with a few simple functions/commands or will this involve editing the IDLE lib files?
Asked something similair before, I wanted to embed the whole IDLE/python shell in my monitoring program, but this seems impossible with the newest python version.
EDIT:
from tkinter import *
import sys, time, threading
global TXT
root = Tk()
TXT = Text(root, font="Arial")
TXT.pack(fill=X)
class RedirectText(object):
def __init__(self, TXT):
self.out = TXT
def write(self, string):
TXT.insert(END, string)
sys.stdout = RedirectText(TXT)
for i in range(10):
print("test", i+1)
def thread():
print("Delayed")
threading.Timer(1, thread).start()
threading.Timer(1, thread).start()
root.mainloop()
Removed all faulty code, now have this. Will not write anything system related, just what is inside a print()
function. Still looking for a way to insert
all system output into a text widget.