# How to do custom rotation sliders and transformation buttons with python?

**URL:** <https://discourse.slicer.org/t/how-to-do-custom-rotation-sliders-and-transformation-buttons-with-python/19747>\
**Category:** Support\
**Tags:** python\
**Created:** [September 19, 2021, 3:25pm UTC](https://discourse.slicer.org/t/how-to-do-custom-rotation-sliders-and-transformation-buttons-with-python/19747 "2021-09-19T15:25:47Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![jmhuie](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jmhuie/32/7086_2.png) [@jmhuie](https://discourse.slicer.org/u/jmhuie)\
**Post date:** [September 19, 2021, 3:25pm UTC](https://discourse.slicer.org/t/how-to-do-custom-rotation-sliders-and-transformation-buttons-with-python/19747/1 "2021-09-19T15:25:47Z")

</div>

Hi all,

I am currently working on a scripted module that requires a user to rotate segments beforehand (currently done in the transforms module). To improve user accessibility, I would like to implement 1 or 2 feature into my module directly. The first option is to create custom transformation sliders that will rotate a segment around its centroid. There is a nice guide for how to initialize rotation around a point [here](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#rotate-a-node-around-a-specified-point). However, I don’t think I can reasonable expect users to set this up themselves and would like to have custom rotation sliders in my module’s GUI that’ll do this. However, I cannot find much documentation on how I would actually implement this. The Room’s Eye View module in SlicerRT does essentially what I want (and way more) but I cannot decipher the source code.

I understand that transformation chains can be complicated so the alternative feature I’d like to add is a button that can access the transforms “interaction in 3D view” feature and toggle it on and off. The only difference I’d want to make is have it initialize the bounds based on a specific node and not all of the nodes for which the transformation is applied (e.g., initialize based on the segment but not the volume node). When initialized based on a segmentation node with a single segment, the interactive 3D box effectively allows the user to rotate the segment around its centroid.

So, I am wondering if there are any resources or python scripted examples with something similar that will point me in the right direction? I would greatly appreciate any help.

Thanks,  
Jonathan

---

_[View the full topic](https://discourse.slicer.org/t/how-to-do-custom-rotation-sliders-and-transformation-buttons-with-python/19747)._
