Printing output in python GUI sometimes in python console, sometimes in terminal issue with qdialog from pyqt

Hello,
as this is quite problematic in some cases and I did not gave an script where this problem showed, I took the time to create a small test where it is reproduced the problematic behavior.

here is a example where when runned it prints the variable ‘bal’ in the salome terminal instead of the python console of salome GUI. I would appreciate any input on this matter as in my real script would like to get the output in the python console.

for info: I need to print ‘bal’ when the custom dialog is accepted and not before it as in the real script, the function testForPrint does some calculations and the print needs to print part of the results. (and the calculations uses some parameters that the user defines in the dialog window, for simplicity i remove all of this).

it clearly comes from the pyqt interaction…
here is the simplified example to reproduce the issue (issue that i have had since 9.7 to 9.14 in linux using universal package (and i think also the one of ubuntu))
exampleOfWrongPrinting.py (982 Bytes)

thanks in advance, any input would be appreciated.