# Button for python code

**URL:** <https://discourse.mcneel.com/t/button-for-python-code/149973>\
**Category:** Rhino Developer\
**Tags:** windows\
**Created:** [November 1, 2022, 10:40am UTC](https://discourse.mcneel.com/t/button-for-python-code/149973 "2022-11-01T10:40:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_GM](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/alex_gm/32/510688_2.png) [@Alex\_GM](https://discourse.mcneel.com/u/Alex_GM)\
**Post date:** [November 1, 2022, 10:40am UTC](https://discourse.mcneel.com/t/button-for-python-code/149973/1 "2022-11-01T10:40:40Z")

</div>

Hello, I wrote the code in python.  
I want to run it from the Rhino button.  
I can’t do it

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/a/4/2/a422a5f091ea7e5adf56177cdc8ffe2259d5933a.png)

---

<div class="post-metadata">

**Author:** ![djordje](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/djordje/32/747634_2.png) [@djordje](https://discourse.mcneel.com/u/djordje)\
**Post date:** [November 1, 2022, 10:52am UTC](https://discourse.mcneel.com/t/button-for-python-code/149973/2 "2022-11-01T10:52:10Z")

</div>

Hello @Alex_GM ,  
Check this reply for a solution (you have to enclose the code):

> [@Python script to Rhino button](https://discourse.mcneel.com/t/python-script-to-rhino-button/38806/2):
>
> Create a new blank button, open the editor then put in the following: ! \_-RunPythonScript ( \<paste entire script in here\> ) HTH, --Mitch

---

<div class="post-metadata">

**Author:** ![Alex\_GM](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/alex_gm/32/510688_2.png) [@Alex\_GM](https://discourse.mcneel.com/u/Alex_GM)\
**Post date:** [November 1, 2022, 12:02pm UTC](https://discourse.mcneel.com/t/button-for-python-code/149973/3 "2022-11-01T12:02:04Z")

</div>

> [@Python script to Rhino button](https://discourse.mcneel.com/t/python-script-to-rhino-button/38806/2):
>
> ! \_-RunPythonScript ( ) HTH, --Mitch

Thank you for spending your time with newbies like me.

---

<div class="post-metadata">

**Author:** ![Helvetosaur](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/helvetosaur/32/635974_2.png) [@Helvetosaur](https://discourse.mcneel.com/u/Helvetosaur)\
**Post date:** [November 1, 2022, 12:11pm UTC](https://discourse.mcneel.com/t/button-for-python-code/149973/4 "2022-11-01T12:11:14Z")

</div>

> [@Alex\_GM](#):
>
> Thank you for spending your time with newbies like me.

With a little help, newbies become oldbies in a very short time… 😜

Concerning running scripts, here is the complete guide:

[https://wiki.mcneel.com/rhino/macroscriptsetup](https://wiki.mcneel.com/rhino/macroscriptsetup)

---

<div class="post-metadata">

**Author:** ![Alex\_GM](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/alex_gm/32/510688_2.png) [@Alex\_GM](https://discourse.mcneel.com/u/Alex_GM)\
**Post date:** [November 1, 2022, 12:26pm UTC](https://discourse.mcneel.com/t/button-for-python-code/149973/5 "2022-11-01T12:26:38Z")

</div>

> [@Python script to Rhino button](https://discourse.mcneel.com/t/python-script-to-rhino-button/38806/2):
>
> HTH

Thank you, I looked here so it did not work

> **[Running a Python script in Rhino](https://developer.rhino3d.com/guides/rhinopython/python-running-scripts/)**
>
> This guide demonstrates how to run a Python script in Rhino.

---

<div class="post-metadata">

**Author:** ![Helvetosaur](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/helvetosaur/32/635974_2.png) [@Helvetosaur](https://discourse.mcneel.com/u/Helvetosaur)\
**Post date:** [November 1, 2022, 3:13pm UTC](https://discourse.mcneel.com/t/button-for-python-code/149973/6 "2022-11-01T15:13:26Z")

</div>

Yes, unfortunately that article is incomplete and lacks some necessary information.
