How to add a checkbox to a panel header? 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.



Any suggestions or leads? I would be grateful for any code examples with it.
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):
    &quot;&quot;&quot;Creates a Panel in the Object properties window&quot;&quot;&quot;
    bl_label = &quot;Hello World Panel&quot;
    bl_idname = &quot;OBJECT_PT_hello&quot;
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = &quot;object&quot;

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


def register():
    bpy.utils.register_class(HelloWorldPanel)


def unregister():
    bpy.utils.unregister_class(HelloWorldPanel)


if __name__ == &quot;__main__&quot;:
    register()