I am bound since it is written on a secret machine, I cannot copy + paste here. As a somewhat newbie, my approach is probably unorthodox.
I have a GUI written in Tkinter with a few buttons. Each button is associated with a class that essentially runs a short script. When the button is clicked, I initialize the log_window class, which is just a Tkinter text widget. Then I create a global variable that binds log with log_window , which I just created, and as the script starts I pipe sys.stdout/stderr to log (for this I created a write method). Everything is kosher, except that the log_window text widget log_window not updated with my standard stdout until the class that calls it is complete. However, if I just print inside the class, it will print in the order in which it is called.
Example
import Tkinter from Tkinter import * import time class log_window: def __init__(self,master): self.textframe = Tkinter.Frame(master) self.text = Text(self.textframe) self.text.pack() self.textframe.pack() def write(self,text): self.text.insert(END,text) class some_func1:
Sorry if my example is a bit confusing, but I think this speaks to the point. I do this through Popen and some system calls, but they are not part of the problem, so I just emphasized that, I suppose, is the LCD of the problem.
source share