Print python to Java swing window

Asked by spyros-liakos on 2018-03-03

I can't figure out how I can redirect the print from my python script to swing window...
I have already a working swing panel with options for my script.

thanx

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
2018-03-03
Last query:
2018-03-03
Last reply:
2018-03-03
Best RaiMan (raimund-hocke) said : #1

You have to replace the Python print statements with your own myPrint() function, that sends the output to the panel.

RaiMan (raimund-hocke) said : #2

The more general solution, to redirect sysout to your panel handler needs an implementation of your own jython scriptrunner in a subprocess using Java (like it is done in SikuliX IDE, where script output goes to the IDE's message area). This only makes sense, if you want to use this solution for some to many other scripts.

As long as you use SikuliX to run your script and have the panel handler directly in your running script, the solution is comment#1

spyros-liakos (spy-arts) said : #3

Can you give simply practical example for your #1 comment....
Thanks

spyros-liakos (spy-arts) said : #4

Thanks RaiMan, that solved my question.

RaiMan (raimund-hocke) said : #5

I am sorry, I do not have the time for such not really SikuliX related things.
... and I have to admit: "simply practical example" is not possible - depending on what you want to achieve: more or less complex.