# SliceWidget change background volume through code

**URL:** <https://discourse.slicer.org/t/slicewidget-change-background-volume-through-code/22838>\
**Category:** Support\
**Created:** [April 5, 2022, 4:11pm UTC](https://discourse.slicer.org/t/slicewidget-change-background-volume-through-code/22838 "2022-04-05T16:11:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fabyan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fabyan/32/14594_2.png) [@Fabyan](https://discourse.slicer.org/u/Fabyan)\
**Post date:** [April 5, 2022, 4:11pm UTC](https://discourse.slicer.org/t/slicewidget-change-background-volume-through-code/22838/1 "2022-04-05T16:11:00Z")

</div>

Hi. As the title suggests, I want to be able to change the volume being viewed inside a single SliceWidget through code.

I can change the volume here but I was wondering if it is possible to do it through code?  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/5/058eea41de3a041f22b8905119421c2a08991529.png)

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [April 5, 2022, 6:44pm UTC](https://discourse.slicer.org/t/slicewidget-change-background-volume-through-code/22838/2 "2022-04-05T18:44:46Z")

</div>

You can find the answer here  
[https://slicer.readthedocs.io/en/latest/developer\_guide/script\_repository.html#iterate-over-current-visible-slice-views-and-set-foreground-and-background-images](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#iterate-over-current-visible-slice-views-and-set-foreground-and-background-images)
