-
-
Notifications
You must be signed in to change notification settings - Fork 0
Buttons
There are 3 requirements to creating a button:
- The function must have 2 parameters
- The function must return operation result, for example
return {"FINISHED"}
- The function must be decorated with
@MakeButton
You can quickly paste a snippet of code with an example button by using the side menu button in the text editor.
Or copy the code below:
@MakeButton("My Tab/My Panel/My Button", "VIEW_3D")
def example_func(self, context):
#Do stuff here
return {"FINISHED"}
There are 2 parameters that the MakeButton
decorator can take:
- Where is the button located:
This is broken down into 3 parts separated by /
symbol. First is the name of the tab, second is the name of panel, and third is the label on the button.
- Which area the button belongs to:
This defaults to VIEW_3D
which is the 3D viewport, check here for more options.
To make a button appear in the NLA editor simply do this:
@MakeButton("My Tab/My Panel/My Button", "NLA_EDITOR")
def example_func(self, context):
#Do stuff here
return {"FINISHED"}
If we run the example code now we will end with up this result:
Any time the function is modified the code needs to be reloaded. To do this, simply run the script containing the function.
Currently the only way to remove old buttons is to open the file again or use the Purge buttons
button:
To ensure the buttons are always created as soon as the file is loaded, every script containing the functions must be registered, to do so you can check the following box:
- Advanced
- Not yet implemented