Is there any way I can modify the below code so I get the stdout output in real time. Currently this prints to a tkinter label when the function is completed and not during the execution.
Below is my code, I have added the flush myself and tried varies permutations but to no avail.
If I understand you correctly, you want to immediately react to blahblah2 writing something to sys.stdout, as opposed to waiting for it to finish and then reading a value from a buffer? If so, you can probably just add the relevant logic to the write method of your file I/O mock-up. Something like
class StdoutRedirector22:
# ...
def write(self, text):
STATUS3['text'] = text
Even better would be if blahblah2 returned a value to begin with instead of writing to stdout. Do you know why it’s doing that / is it something under your control?
If there are functions below a class definition, and there is no indentation, this will imply that they are not methods of the class (independent functions). However, if they are indented, then this specifies that they belong to the class.
… you still need to correct the syntactic errors in your “updated” script.