# Changes applied in a python script propagate only to the GUI but don't get displayed

**URL:** <https://discourse.slicer.org/t/changes-applied-in-a-python-script-propagate-only-to-the-gui-but-dont-get-displayed/21519>\
**Category:** Support\
**Tags:** views\
**Created:** [January 18, 2022, 6:28pm UTC](https://discourse.slicer.org/t/changes-applied-in-a-python-script-propagate-only-to-the-gui-but-dont-get-displayed/21519 "2022-01-18T18:28:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![koeglfryderyk](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/koeglfryderyk/32/14638_2.png) [@koeglfryderyk](https://discourse.slicer.org/u/koeglfryderyk)\
**Post date:** [January 18, 2022, 6:28pm UTC](https://discourse.slicer.org/t/changes-applied-in-a-python-script-propagate-only-to-the-gui-but-dont-get-displayed/21519/1 "2022-01-18T18:28:48Z")

</div>

I’m trying to write a script that applies a color gradient to a markups curve.

All the changes are visible in the GUI, but the displayed curve does not change. To change the curve I have to manually click on something in the GUi (to update it?).

This is my code

```auto
# get color table
iron = slicer.util.getFirstNodeByName("Iron")

curveNode = slicer.mrmlScene.GetFirstNodeByName("MarkupsCurve_2")
dispNode = curveNode.GetDisplayNode()
dispNode.SetActiveScalarName("PedigreeIDs")
dispNode.SetAndObserveColorNodeID(iron.GetID())
dispNode.SetScalarVisibility(1)

```

This is how it looks after the code is executed (the Iron color table is not applied):

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/7/878a6e97933e1e0a7effb41ee2e372fe6a167b72.png)

Then, if I e.g. click twice on the ‘Visibile:’ checkbox, the view gets updated (the Iron color table is applied):

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/9/b9950ebe1a5b41844ea815ecc6287309b5b90be2.png)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [January 18, 2022, 8:31pm UTC](https://discourse.slicer.org/t/changes-applied-in-a-python-script-propagate-only-to-the-gui-but-dont-get-displayed/21519/2 "2022-01-18T20:31:04Z")

</div>

You can make the coloring appear like this:

```python
iron = slicer.util.getFirstNodeByName("Iron")
curveNode = slicer.mrmlScene.GetFirstNodeByName("OC")
dispNode = curveNode.GetDisplayNode()
dispNode.SetAndObserveColorNodeID(iron.GetID())
dispNode.SetActiveScalarName("PedigreeIDs")
dispNode.SetScalarVisibility(1)
dispNode.UpdateAssignedAttribute()
dispNode.Modified()

```

The last two lines should not be needed (should be called automatically internally) - I’ll fix that soon in Slicer core.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [January 18, 2022, 9:09pm UTC](https://discourse.slicer.org/t/changes-applied-in-a-python-script-propagate-only-to-the-gui-but-dont-get-displayed/21519/3 "2022-01-18T21:09:04Z")

</div>

The issue is now [fixed](https://github.com/Slicer/Slicer/commit/60042b1ef63ef262289a6d1ea0eaa6399d5cbcde), in Slicer Preview Releases downloaded tomorrow or later the last two lines of the script above will not be necessary anymore.
