# Use button widget to run function

**URL:** <https://discourse.slicer.org/t/use-button-widget-to-run-function/13945>\
**Category:** Development\
**Created:** [October 8, 2020, 10:11pm UTC](https://discourse.slicer.org/t/use-button-widget-to-run-function/13945 "2020-10-08T22:11:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nm19](https://avatars.discourse-cdn.com/v4/letter/n/6bbea6/32.png) [@nm19](https://discourse.slicer.org/u/nm19)\
**Post date:** [October 8, 2020, 10:11pm UTC](https://discourse.slicer.org/t/use-button-widget-to-run-function/13945/1 "2020-10-08T22:11:08Z")

</div>

Hi,

I want to use the basic example module layout to test the functionality of a function I wrote. Essentially, when the foo bar widget is clicked, this function is called and a node should be returned. Any resources on how to approach this?

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:** [October 9, 2020, 2:14am UTC](https://discourse.slicer.org/t/use-button-widget-to-run-function/13945/2 "2020-10-09T02:14:22Z")

</div>

See [Scripting and module development tutorial](https://github.com/PerkLab/PerkLabBootcamp/blob/master/Doc/day3_2_SlicerProgramming.pptx?raw=true) on the [training page](https://www.slicer.org/wiki/Documentation/Nightly/Training#PerkLab.27s_Slicer_bootcamp_training_materials).

---

<div class="post-metadata">

**Author:** ![nm19](https://avatars.discourse-cdn.com/v4/letter/n/6bbea6/32.png) [@nm19](https://discourse.slicer.org/u/nm19)\
**Post date:** [October 9, 2020, 10:51pm UTC](https://discourse.slicer.org/t/use-button-widget-to-run-function/13945/3 "2020-10-09T22:51:20Z")

</div>

Thanks, is there an equivalent tutorial that goes as in depth for loadable modules? I couldn’t find any.

---

<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:** [October 10, 2020, 12:08am UTC](https://discourse.slicer.org/t/use-button-widget-to-run-function/13945/4 "2020-10-10T00:08:11Z")

</div>

Architecture & design concepts are the same for both C++ and Python loadable modules. Syntax difference between Python and C++ is expected to be manageable by C++ developers, but if anything is not clear then let us know here and we can help.
