SVN maintenance.
[blender-staging.git] / doc / python_api / examples / bpy.types.Panel.1.py
1 """
2 Simple Object Panel
3 +++++++++++++++++++
4 This panel has a :class:`Panel.poll` and :class:`Panel.draw_header` function,
5 even though the contents is basic this closely resemples blenders panels.
6 """
7 import bpy
8
9
10 class ObjectSelectPanel(bpy.types.Panel):
11     bl_idname = "OBJECT_PT_select"
12     bl_label = "Select"
13     bl_space_type = 'PROPERTIES'
14     bl_region_type = 'WINDOW'
15     bl_context = "object"
16     bl_options = {'DEFAULT_CLOSED'}
17
18     @classmethod
19     def poll(cls, context):
20         return (context.object is not None)
21
22     def draw_header(self, context):
23         layout = self.layout
24         obj = context.object
25         layout.prop(obj, "select", text="")
26         
27
28     def draw(self, context):
29         layout = self.layout
30
31         obj = context.object
32         row = layout.row()
33         row.prop(obj, "hide_select")
34         row.prop(obj, "hide_render")
35
36         box = layout.box()
37         box.label("Selection Tools")
38         box.operator("object.select_all")
39         row = box.row()
40         row.operator("object.select_inverse")
41         row.operator("object.select_random")
42
43
44 bpy.utils.register_class(ObjectSelectPanel)