Created
August 10, 2016 10:01
-
-
Save sambler/2cdafb820dfdd5044b33421d8df706e2 to your computer and use it in GitHub Desktop.
Example of creating sub panels in blender
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# made in response to http://blender.stackexchange.com/q/60583/935 | |
bl_info = { | |
"version": (1, 0), | |
"blender": (2, 75, 0), | |
"author": "sambler", | |
"name": "Sample Panel with subpanels addon", | |
"description": """Sample addon to demonstrate displaying sub-panels within a panel""" , | |
"category": "test", | |
} | |
import bpy | |
class MultiDataPanel(bpy.types.Panel): | |
"""testing panel showing multiple subpanels""" | |
bl_label = 'Multi data Panel' | |
bl_idname = 'OBJECT_PT_multidata' | |
bl_space_type = 'VIEW_3D' | |
bl_region_type = 'TOOLS' | |
def draw(self, context): | |
scn = context.scene | |
layout = self.layout | |
box = layout.box() | |
col = box.column() | |
row = col.row() | |
if scn.show_options_01: | |
row.prop(scn, "show_options_01", icon="DOWNARROW_HLT", text="", emboss=False) | |
else: | |
row.prop(scn, "show_options_01", icon="RIGHTARROW", text="", emboss=False) | |
row.label('First sub panel') | |
if scn.show_options_01: | |
# Add items from other panels draw method here | |
row = col.row() | |
row.label('Render resolution') | |
row = col.row() | |
col = row.column(align=True) | |
col.prop(scn.render, 'resolution_x', text='X') | |
col.prop(scn.render, 'resolution_y', text='Y') | |
row = col.row() | |
row.label('and more rows for other data') | |
# end of other panels draw method | |
box = layout.box() | |
col = box.column() | |
row = col.row() | |
if scn.show_options_02: | |
row.prop(scn, "show_options_02", icon="DOWNARROW_HLT", text="", emboss=False) | |
else: | |
row.prop(scn, "show_options_02", icon="RIGHTARROW", text="", emboss=False) | |
row.label('Second sub panel') | |
if scn.show_options_02: | |
# Add items from other panels draw method here | |
row = col.row() | |
row.label('Frame range') | |
row = col.row() | |
col = row.column(align=True) | |
col.prop(scn, 'frame_start', text='Start Frame') | |
col.prop(scn, 'frame_end', text='End Frame') | |
col.prop(scn, 'frame_step', text='Frame Step') | |
row = col.row() | |
row.label('and more rows for other data') | |
# end of other panels draw method | |
box = layout.box() | |
col = box.column() | |
row = col.row() | |
if scn.show_options_03: | |
row.prop(scn, "show_options_03", icon="DOWNARROW_HLT", text="", emboss=False) | |
else: | |
row.prop(scn, "show_options_03", icon="RIGHTARROW", text="", emboss=False) | |
row.label('Third sub panel') | |
if scn.show_options_03: | |
# Add items from other panels draw method here | |
row = col.row() | |
row.label('Render output') | |
row = col.row() | |
col = row.column(align=True) | |
col.prop(scn.render, 'filepath') | |
row = col.row() | |
row.label('and more rows for other data') | |
# end of other panels draw method | |
def register(): | |
bpy.utils.register_class(MultiDataPanel) | |
bpy.types.Scene.show_options_01 = bpy.props.BoolProperty(name='Show 1st panel', default=False) | |
bpy.types.Scene.show_options_02 = bpy.props.BoolProperty(name='Show 2nd panel', default=False) | |
bpy.types.Scene.show_options_03 = bpy.props.BoolProperty(name='Show 3rd panel', default=False) | |
def unregister(): | |
del bpy.types.Scene.show_options_01 | |
del bpy.types.Scene.show_options_02 | |
del bpy.types.Scene.show_options_03 | |
bpy.utils.unregister_class(MultiDataPanel) | |
if __name__ == "__main__": | |
register() | |
# Redistribution and use in source and binary forms, with or without | |
# modification, are permitted provided that the following conditions are | |
# met: | |
# | |
# * Redistributions of source code must retain the above copyright | |
# notice, this list of conditions and the following disclaimer. | |
# * Redistributions in binary form must reproduce the above | |
# copyright notice, this list of conditions and the following disclaimer | |
# in the documentation and/or other materials provided with the | |
# distribution. | |
# | |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment