# How to toggle slice display in 3D using python code?

**URL:** <https://discourse.slicer.org/t/how-to-toggle-slice-display-in-3d-using-python-code/25157>\
**Category:** Support\
**Tags:** python, 3d-model, module\
**Created:** [September 8, 2022, 1:55pm UTC](https://discourse.slicer.org/t/how-to-toggle-slice-display-in-3d-using-python-code/25157 "2022-09-08T13:55:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sunshine](https://avatars.discourse-cdn.com/v4/letter/s/3ec8ea/32.png) [@sunshine](https://discourse.slicer.org/u/sunshine)\
**Post date:** [September 8, 2022, 1:55pm UTC](https://discourse.slicer.org/t/how-to-toggle-slice-display-in-3d-using-python-code/25157/1 "2022-09-08T13:55:16Z")

</div>

Hi everyone,

I have a question about window control using python codes.

What are the possible functions to call in order to to toggle slice display in 3D using python code?

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/7/17e24dbedd5e92818b1e465f16c3442b4e48249d.png)

Thank you so much in advance!

---

<div class="post-metadata">

**Author:** ![Sunderlandkyl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sunderlandkyl/32/79987_2.png) [@Sunderlandkyl](https://discourse.slicer.org/u/Sunderlandkyl)\
**Post date:** [September 8, 2022, 2:18pm UTC](https://discourse.slicer.org/t/how-to-toggle-slice-display-in-3d-using-python-code/25157/2 "2022-09-08T14:18:16Z")

</div>

You can toggle slice visibility like this:

```python
sliceNode = getFirstNodeByClassByName("vtkMRMLSliceNode", "Red")
sliceNode.SetSliceVisible(True)

```

---

<div class="post-metadata">

**Author:** ![sunshine](https://avatars.discourse-cdn.com/v4/letter/s/3ec8ea/32.png) [@sunshine](https://discourse.slicer.org/u/sunshine)\
**Post date:** [September 8, 2022, 2:56pm UTC](https://discourse.slicer.org/t/how-to-toggle-slice-display-in-3d-using-python-code/25157/3 "2022-09-08T14:56:44Z")

</div>

Thank you so much, Kyle!
