# Get active cell from loaded table

**URL:** <https://discourse.slicer.org/t/get-active-cell-from-loaded-table/10882>\
**Category:** Support\
**Created:** [March 27, 2020, 11:38pm UTC](https://discourse.slicer.org/t/get-active-cell-from-loaded-table/10882 "2020-03-27T23:38:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![smrolfe](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/smrolfe/32/3659_2.png) [@smrolfe](https://discourse.slicer.org/u/smrolfe)\
**Post date:** [March 27, 2020, 11:38pm UTC](https://discourse.slicer.org/t/get-active-cell-from-loaded-table/10882/1 "2020-03-27T23:38:41Z")

</div>

I’d like to access the active (highlighted) cell in a table in the MRML scene from the Python interactor. I thought this property might be in the vtkMRMLTableNode or vtkMRMLTableViewNode. Is there someplace else I should look? Thanks!

---

<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:** [March 28, 2020, 1:53am UTC](https://discourse.slicer.org/t/get-active-cell-from-loaded-table/10882/2 "2020-03-28T01:53:50Z")

</div>

You can get selected column indices using [qMRMLTableView::selectedMRMLTableColumnIndices()](http://apidocs.slicer.org/master/classqMRMLTableView.html#a28f7ca3bf653ed03342789ad348f19b9)`. Feel free to add more methods (for example to return (row,col) indices, or use more Python-friendly return types) and send a pull request.

Table view also has a `selectionChanged()` signal that you can observe to get notified when selection is changed.

---

<div class="post-metadata">

**Author:** ![smrolfe](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/smrolfe/32/3659_2.png) [@smrolfe](https://discourse.slicer.org/u/smrolfe)\
**Post date:** [March 28, 2020, 3:11am UTC](https://discourse.slicer.org/t/get-active-cell-from-loaded-table/10882/3 "2020-03-28T03:11:05Z")

</div>

Thanks @lassoan. I can get the qMRMLTableView when I instantiate the widget, could you explain how to get it from the scene?

---

<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:** [March 28, 2020, 9:57pm UTC](https://discourse.slicer.org/t/get-active-cell-from-loaded-table/10882/4 "2020-03-28T21:57:21Z")

</div>

Would you like to access a table view that is in the view layout?

You can access it by calling `slicer.app.layoutManager().tableWidget(0).tableView()`.

---

<div class="post-metadata">

**Author:** ![smrolfe](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/smrolfe/32/3659_2.png) [@smrolfe](https://discourse.slicer.org/u/smrolfe)\
**Post date:** [March 30, 2020, 3:18pm UTC](https://discourse.slicer.org/t/get-active-cell-from-loaded-table/10882/5 "2020-03-30T15:18:31Z")

</div>

Thanks @lassoan! This works perfectly.
