I tried the gui example for console and made some modifications. Works well, redirection of input, output of python works
The main difference is the REPL (read, eval, print) behaviour.
in a normal shell typing e.g. a normal variable will print the value, or if i call 10+10 the result is printed. In the example if have to explicit call print()
Does anybody know how to print out the last result like in normal python console?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The evaluation of Python code only returns a value if used in single line parsing mode, there is an enum for that. The call will then return the value as QVariant, which you can print with Qt.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It is even better: the python does it automatically. It creates a "_" variable and prints the value via normal stdout. Nothing to implement. Extra impl would be necessary if you want to do something like the ipython console, but this is not required for us.
Thanks
Last edit: Joerg Kreuzberger 2017-09-07
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi!
I tried the gui example for console and made some modifications. Works well, redirection of input, output of python works
The main difference is the REPL (read, eval, print) behaviour.
in a normal shell typing e.g. a normal variable will print the value, or if i call 10+10 the result is printed. In the example if have to explicit call print()
Does anybody know how to print out the last result like in normal python console?
The evaluation of Python code only returns a value if used in single line parsing mode, there is an enum for that. The call will then return the value as QVariant, which you can print with Qt.
It is even better: the python does it automatically. It creates a "_" variable and prints the value via normal stdout. Nothing to implement. Extra impl would be necessary if you want to do something like the ipython console, but this is not required for us.
Thanks
Last edit: Joerg Kreuzberger 2017-09-07