Is it possible to add a new button to an existing panel or an existing node that runs a custom operator?

How can I do this?


Yes. You need to find the class that defines that panel (usually pretty easy to do by right-clicking a button or setting in the panel and choosing Edit Source). From there, you just need to define a function and append it to that class. As an example, I do this in my Render Music add-on (in __init__.py, starting at line 82). Below is the relevant example that adds two checkboxes (properties defined by the add-on) to the Render Panel (RENDER_PT_render):

def render_panel(self, context):
    user_prefs = context.user_preferences
    addon_prefs = user_prefs.addons[__package__].preferences

    layout = self.layout
    layout.prop(addon_prefs, "use_play")
    layout.prop(addon_prefs, "use_end")

# Registration

def register():
|improve this answer|||||
  • 2
    $\begingroup$ You explain how to add a panel to another, but not how to remove in the unregister method. I believe it is by using remove instead of append. $\endgroup$ – JakeD Nov 16 '16 at 3:27
  • $\begingroup$ Yes. That is correct. I left it off in the reply because I didn't want to confuse the issue too much. The unregister function is in the full source that's linked, though. $\endgroup$ – Fweeb Nov 16 '16 at 12:36
  • $\begingroup$ Note: Edit Source is available by enabling "Developer Extras" in the preferences menu (Preferences > Interface ). $\endgroup$ – Zollie Feb 13 at 18:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.