How to use Screen Capture Module to save slices as .png files one-by-one along one axial?

Hi,Mike.
Sorry for reopening this topic,but I think you may help me.As we said before,

  1. iterates through the I-S range values of Volume Rendering
  2. takes a screenshot of the 3D window

No problem with the above two and I have created a python Script Module for that,however,every time I move the ROI and take a screenshot , the 3D window does not display the corresponding ROI area. Is there a way to dynamically display the ROI movement in real time?
By the way, I attached the source code of the module.https://github.com/ningmenghongcha/takeScreenshots

By the way did you check out the Animator module in SlicerMorph extension. It simplifies going ROI and volume rendering quite a lot. See an older demo here:

You may just need to add a call to slicer.app.processEvents() in your loop to trigger the update of the 3D window display.

1 Like

It really works!Thank you very very much,Mike.You saved my a lot of work!
It seems like this function calls a thread to process the events,so I can do other things in Slicer application.
I have a question as follows,
At first,if I don’t call this function,the Slicer application looks dead and no response in that case user can not interfere the event.But if I call this function to update in real time,in the meantime,I can rotate the image in 3D window so the screenshots are not correct at last.
Can I add a lock to prevent other changes made in 3D window, such as zoom-in or rotation when moving roi and taking screenshots?

Try passing the qt.QEventLoop.ExcludeUserInputEvents value as a flag to the processEvents call.

https://doc.qt.io/qt-5/qcoreapplication.html#processEvents

2 Likes