I'm trying to find out how to add a checkbox to a panel header so panel can be deacivated (as well as storing that checkbox value in some property). It may be quite obious task, but I didn't find any info about it in the docs so far.

Example of what I'm trying to achive is the "Gravity" panel, that can be turned off with the checkbox.

Example of what i'm trying to achive

Any suggestions or leads? I would be grateful for any code examples with it.


2 Answers 2


Add draw_header(context) function to your Panel class and supply any bool property. Following example is based on ui_panel_simple.py template:

import bpy

class HelloWorldPanel(bpy.types.Panel):
    """Creates a Panel in the Object properties window"""
    bl_label = "Hello World Panel"
    bl_idname = "OBJECT_PT_hello"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "object"

    def draw_header(self,context):
        # Example property to display a checkbox, can be anything
        self.layout.prop(context.scene.render, "use_border", text="")
    def draw(self, context):
        layout = self.layout
        layout.label(text="Hello world!", icon='WORLD_DATA')

def register():

def unregister():

if __name__ == "__main__":

Adding to already registered panels

As an extra to other answers re defining a draw header on a new panel class, can monkey around with existing panel classes.

Here is an example that adds gravity checkbox and "XXX" to audio panel header, and disables that panels layout with scene.use_gravity (silly)

enter image description here

import bpy
from bl_ui.properties_scene import SCENE_PT_audio

dr = SCENE_PT_audio.draw

def draw(self, context):
    scene = context.scene
    layout = self.layout
    layout.enabled = scene.use_gravity
    dr(self, context)

def draw_header(self, context):
    scene = context.scene
    self.layout.prop(scene, "use_gravity", text="XXX")

if SCENE_PT_audio.is_registered:    
SCENE_PT_audio.draw = draw   
SCENE_PT_audio.draw_header = draw_header

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .