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

**URL:** <https://discourse.slicer.org/t/how-to-use-screen-capture-module-to-save-slices-as-png-files-one-by-one-along-one-axial/21336>\
**Category:** Support\
**Tags:** screen-capture\
**Created:** [January 5, 2022, 11:52am UTC](https://discourse.slicer.org/t/how-to-use-screen-capture-module-to-save-slices-as-png-files-one-by-one-along-one-axial/21336 "2022-01-05T11:52:49Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![user4](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/user4/32/13172_2.png) [@user4](https://discourse.slicer.org/u/user4)\
**Post date:** [July 13, 2022, 2:07am UTC](https://discourse.slicer.org/t/how-to-use-screen-capture-module-to-save-slices-as-png-files-one-by-one-along-one-axial/21336/25 "2022-07-13T02:07:34Z")

</div>

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](https://github.com/ningmenghongcha/takeScreenshots)

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [July 13, 2022, 3:21am UTC](https://discourse.slicer.org/t/how-to-use-screen-capture-module-to-save-slices-as-png-files-one-by-one-along-one-axial/21336/26 "2022-07-13T03:21:43Z")

</div>

By the way did you check out the [Animator module in SlicerMorph extension](https://github.com/SlicerMorph/SlicerMorph/tree/master/Docs/Animator). It simplifies going ROI and volume rendering quite a lot. See an [older demo here:](https://www.youtube.com/watch?v=9GBekYcJR4E)

---

<div class="post-metadata">

**Author:** ![mikebind](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@mikebind](https://discourse.slicer.org/u/mikebind)\
**Post date:** [July 13, 2022, 3:55pm UTC](https://discourse.slicer.org/t/how-to-use-screen-capture-module-to-save-slices-as-png-files-one-by-one-along-one-axial/21336/27 "2022-07-13T15:55:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![user4](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/user4/32/13172_2.png) [@user4](https://discourse.slicer.org/u/user4)\
**Post date:** [July 14, 2022, 2:35am UTC](https://discourse.slicer.org/t/how-to-use-screen-capture-module-to-save-slices-as-png-files-one-by-one-along-one-axial/21336/28 "2022-07-14T02:35:40Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [July 14, 2022, 3:26am UTC](https://discourse.slicer.org/t/how-to-use-screen-capture-module-to-save-slices-as-png-files-one-by-one-along-one-axial/21336/29 "2022-07-14T03:26:38Z")

</div>

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

[https://doc.qt.io/qt-5/qcoreapplication.html#processEvents](https://doc.qt.io/qt-5/qcoreapplication.html#processEvents)

[Previous page](https://discourse.slicer.org/t/how-to-use-screen-capture-module-to-save-slices-as-png-files-one-by-one-along-one-axial/21336.md?page=1)
