Print output does not immediately appear in Python console

May I ask a basic question. In my python script I keep printing messages using Python’s print() commant. However, these messasges will not appear instantly! For example, if the user pushes a button in my Python plugin, a long script is executed and in the mittle I have inserted print commands. However, none of them appear, until the entire function of the button is executed! Is there an easy way to fix this? Thanks.

You need to give a chance for the application to paint the messages into the console. The easiest way to do it is to call slicer.app.processEvents() after the print command.

Thanks a lot! It worked like a charm!!!

1 Like