0

I have designed a GUI in Java using Swing.

Using GUI I read the location as inputs

Using these inputs as parameter I call a Python Script from this Java Code

Now, I need to display the output of the python script on GUI dynamically. As the python script runs the output log of the script has to be displayed on the GUI area simultaneously.

Is there anyway I can do that ?

Please help

msa
  • 31
  • 1
  • 7

1 Answers1

0

A code would be useful, however, you could write the python script output on a file and than read that output from that file to the Java GUI.

Python

out_file = open("test.txt","w")
out_file.write("This Text is going to out file\nLook at it and see\n")
out_file.close()

JAVA

File name = new File("C:/path/test.txt");

if (name.isFile()) {

    try {

        BufferedReader input = new BufferedReader(new FileReader(name));
        StringBuffer buffer = new StringBuffer();

        String text;

        while ((text = input.readLine()) != null){

             buffer.append(text + "\n");}

        input.close();
        System.out.println(buffer.toString());

    } catch (IOException ioException) {}

}
Mitro
  • 1,230
  • 8
  • 32
  • 61