Cleanup: use staticmethod where appropriate
[blender.git] / release / scripts / templates_py / ui_panel.py
1 import bpy
2
3
4 class LayoutDemoPanel(bpy.types.Panel):
5     """Creates a Panel in the scene context of the properties editor"""
6     bl_label = "Layout Demo"
7     bl_idname = "SCENE_PT_layout"
8     bl_space_type = 'PROPERTIES'
9     bl_region_type = 'WINDOW'
10     bl_context = "scene"
11
12     def draw(self, context):
13         layout = self.layout
14
15         scene = context.scene
16
17         # Create a simple row.
18         layout.label(text=" Simple Row:")
19
20         row = layout.row()
21         row.prop(scene, "frame_start")
22         row.prop(scene, "frame_end")
23
24         # Create an row where the buttons are aligned to each other.
25         layout.label(text=" Aligned Row:")
26
27         row = layout.row(align=True)
28         row.prop(scene, "frame_start")
29         row.prop(scene, "frame_end")
30
31         # Create two columns, by using a split layout.
32         split = layout.split()
33
34         # First column
35         col = split.column()
36         col.label(text="Column One:")
37         col.prop(scene, "frame_end")
38         col.prop(scene, "frame_start")
39
40         # Second column, aligned
41         col = split.column(align=True)
42         col.label(text="Column Two:")
43         col.prop(scene, "frame_start")
44         col.prop(scene, "frame_end")
45
46         # Big render button
47         layout.label(text="Big Button:")
48         row = layout.row()
49         row.scale_y = 3.0
50         row.operator("render.render")
51
52         # Different sizes in a row
53         layout.label(text="Different button sizes:")
54         row = layout.row(align=True)
55         row.operator("render.render")
56
57         sub = row.row()
58         sub.scale_x = 2.0
59         sub.operator("render.render")
60
61         row.operator("render.render")
62
63
64 def register():
65     bpy.utils.register_class(LayoutDemoPanel)
66
67
68 def unregister():
69     bpy.utils.unregister_class(LayoutDemoPanel)
70
71
72 if __name__ == "__main__":
73     register()