Display external process output in module GUI

Hi Andras,
I wrote a scripted module and I am calling an external python using subprocess_checkoutput.

Is there a way to get the terminal output into a GUI component to let the user of a module know about the program is still running.

Which GUI component is good for displaying the program processing?
how can I capture the terminal output?

regards,
Saima

how can I get the gui box with errors and progress bar in python scripted module

image

You can have a look at other modules that print process output in the module GUI, for example TotalSegmentator.

Hi Andras,
Could you please let me know which part of the code refers to the output display and what is the name of the GUI component used.

regards,
Saima

The line that I posted the link to (self.logProcessOutput()) notifies the GUI about the new output by calling the self.log callback. I would recommend to attach a debugger add a breakpoint in logProcessOutput and execute the code step by step so that you can see what methods are called, check type of any variables, etc.

Sorry Andras, but I am finding it hard to see how the textbox below the apply button is attached to the log for displaying all the output.

Could you please help. I simply want to display the back end interpreter outputs in the textbox while the program is running.
regards,
Saima

Hi andras,
Thank you so much I managed to use the code from totalsegmentator to output the interpreter output into the GUI component.

Thank you

regards.,
saima

1 Like

Hi Andras,
I did the implementation and it shows output correctly but I do not understand about logCallback

regards,
Saima

You can search on the web for “Python callback” or “Python hook” for more information. For example: python - How can I provide a "callback" to an API? - Stack Overflow

Hi Andras,
Thank you so much for all your suggestions and help.

could you please suggest the best way to avoid any force quit by slicer. I successfully wrote the python scripted module. The purpose is to run 300 images and get the segmentation automatically using bratstoolkit and managing the directories it create for 300 images. On top of that I am using 3D Slicer to apply the transform to the segmented region of interest to get it aligned with the original MRI for each of these images and saving the transformed segmentation.

The slicer windows pop up telling to force quit or wait? how to get rid of this issue? I did wait every time and then it runs fine but how to avoid this issue?

Also i am using the nightly build version of slicer not the stable release.

Thank you

regards,
Saima

The question in this topic has been answered. If you have a new question then please create a new topic. Be specific. If you just say that Slicer hangs but we don’t know what you did then of course we have no idea what to do about it.