# Extension to execute python function

**URL:** <https://discourse.slicer.org/t/extension-to-execute-python-function/31478>\
**Category:** Feature requests\
**Created:** [August 31, 2023, 3:35pm UTC](https://discourse.slicer.org/t/extension-to-execute-python-function/31478 "2023-08-31T15:35:15Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [August 31, 2023, 3:44pm UTC](https://discourse.slicer.org/t/extension-to-execute-python-function/31478/2 "2023-08-31T15:44:12Z")

</div>

This example may help:

> [@How to add button on 2d or 3d window?](https://discourse.slicer.org/t/how-to-add-button-on-2d-or-3d-window/31174/2):
>
> Good question - this code seems to work. You’d need to add some extra code if you want to have it show up in the lower right corner and track window resizes and things. \>\>\> sliceButton = qt.QPushButton("Slice") \>\>\> sliceButton.setParent(slicer.app.layoutManager().sliceWidget("Red")) \>\>\> sliceButton.geometry = qt.QRect(0,0,200,200) \>\>\> sliceButton.show() \>\>\>

---

_[View the full topic](https://discourse.slicer.org/t/extension-to-execute-python-function/31478)._
