""##############################################################################first-cut implementation of file-like classes that can be used to redirect input and output streams to gui displaysas isinput comes from common dialog pop-up ( single output+input interface or persistent entry field for input would be better)this also does not properly span lines for read requests with byte count len(line)could also add __iter__/__next__ to guiinput to support line iteration like files but would be too many popups##############################################################################""from tkinter import from tkinter simpledialog import askstring from tkinter scrolledtext import scrolledtext class guioutputfont ('courier' 'normal'def __init__(selfparent=none)self text none if parentself popupnow(parentor pp gui tour scrolledtext in class for allself for one pop up now or on first write def popupnow(selfparent=none)in parent nowtoplevel later if self textreturn self text scrolledtext(parent or toplevel()self text config(font=self fontself text pack(def write(selftext)self popupnow(self text insert(endstr(text)self text see(endself text update(update gui after each line def writelines(selflines)for line in linesself write(linelines already have '\nor map(self writelinesclass guiinputdef __init__(self)self buff 'def inputline(self)line askstring('guiinput''enter input line (cancel=eof)'if line =nonereturn 'pop-up dialog for each line elsecancel button means eof return line '\nelse add end-line marker def read(selfbytes=none)if not self buffself buff self inputline(if bytestext self buff[:bytesself buff self buff[bytes:else gui coding techniques read by byte count doesn' span lines