# Access Color Node from Colors Widget (python)

**URL:** <https://discourse.slicer.org/t/access-color-node-from-colors-widget-python/4752>\
**Category:** Support\
**Tags:** python\
**Created:** [November 13, 2018, 9:55pm UTC](https://discourse.slicer.org/t/access-color-node-from-colors-widget-python/4752 "2018-11-13T21:55:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Valtiel](https://avatars.discourse-cdn.com/v4/letter/v/839c29/32.png) [@Valtiel](https://discourse.slicer.org/u/Valtiel)\
**Post date:** [November 13, 2018, 9:55pm UTC](https://discourse.slicer.org/t/access-color-node-from-colors-widget-python/4752/1 "2018-11-13T21:55:00Z")

</div>

Hi!

I managed to connect the colors widget via `slicer.modules.colors.widgetRepresentation`.  
Now I want to use the color node from the ColorTableComboBox, but I can’t access it.

Basically, my code would be:  
self.visualization\_button.enabled = True  
displayNode = self.uncertainty\_selector.currentNode().GetScalarVolumeDisplayNode()  
colormap = self.colormap\_selector.ColorTableComboBox.getNode()  
displayNode.SetAndObserveColorNodeID(colormap)

However, python can’t find this combobox. How can I access the colorNode?  
Thanks in advance!

Operating system: Windows 10  
Slicer version: 4.10.0

---

<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:** [November 14, 2018, 5:53am UTC](https://discourse.slicer.org/t/access-color-node-from-colors-widget-python/4752/2 "2018-11-14T05:53:33Z")

</div>

Would you like to change the currently selected color node in the Colors module? Or you would like to add a color table or a color node selector into your own module GUI?

---

<div class="post-metadata">

**Author:** ![Valtiel](https://avatars.discourse-cdn.com/v4/letter/v/839c29/32.png) [@Valtiel](https://discourse.slicer.org/u/Valtiel)\
**Post date:** [November 14, 2018, 4:41pm UTC](https://discourse.slicer.org/t/access-color-node-from-colors-widget-python/4752/3 "2018-11-14T16:41:20Z")

</div>

I want to apply the currenty selected color node in the Colors Module to a displayNode via `displayNode.SetAndBoserveColorNodeID(ColorNode)`, but I can’t access the selected colorNode.

EDIT:  
In the source code of qSlicerColorsModuleWidget.cxx, there is a pointer `d` that is used to access the `ColorTableComboBox` from `SlicerColorsModuleWidgetPrivate`, like in Line 370, for example:  
`d->ColorTableComboBox->currentNode()`. I want that exact node.

---

<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:** [November 15, 2018, 1:05am UTC](https://discourse.slicer.org/t/access-color-node-from-colors-widget-python/4752/4 "2018-11-15T01:05:16Z")

</div>

In general, you are not supposed to access GUI of other modules but instead you can communicate with them using MRML and module logic classes.

For selecting a color node, you can put a node selector widget on your module GUI. Would that work for you?

---

<div class="post-metadata">

**Author:** ![Valtiel](https://avatars.discourse-cdn.com/v4/letter/v/839c29/32.png) [@Valtiel](https://discourse.slicer.org/u/Valtiel)\
**Post date:** [November 15, 2018, 9:05am UTC](https://discourse.slicer.org/t/access-color-node-from-colors-widget-python/4752/5 "2018-11-15T09:05:50Z")

</div>

I see, my bad.

I’ll try using the node selector widget, I guess that should work, too. Thank you!

---

<div class="post-metadata">

**Author:** ![Valtiel](https://avatars.discourse-cdn.com/v4/letter/v/839c29/32.png) [@Valtiel](https://discourse.slicer.org/u/Valtiel)\
**Post date:** [November 15, 2018, 10:10am UTC](https://discourse.slicer.org/t/access-color-node-from-colors-widget-python/4752/6 "2018-11-15T10:10:24Z")

</div>

I did it!  
I used the `slicer.qMRMLColorPickerWidget()` to select a premade color node and accessed it via `.currentColorNode().GetID()` to set it as the ColorNode for my DisplayNode. Thank you!
