Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make popup windows dynamic #15

Open
schlegelp opened this issue Jun 11, 2018 · 0 comments
Open

make popup windows dynamic #15

schlegelp opened this issue Jun 11, 2018 · 0 comments

Comments

@schlegelp
Copy link
Owner

Show additional options only upon changing dropdown/ticking a box. See this example using check():

import bpy


def main(context):
    for ob in context.scene.objects:
        print(ob)
        
class SimplePanel(bpy.types.Panel):
    """Creates Import Menu in Properties -> Scene """
    bl_label = "Test"
    bl_space_type = "PROPERTIES"
    bl_region_type = "WINDOW"
    bl_context = "scene"

    def draw(self, context):
        layout = self.layout
        
        row = layout.row(align=True)
        row.alignment = 'EXPAND'
        row.operator("object.simple_operator", text = "Run", icon ='VISIBLE_IPO_ON')

class SimpleOperator(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"
    bl_options = {'REGISTER', 'UNDO'}

    val1 = bpy.props.BoolProperty()
    val2 = bpy.props.BoolProperty()
    val3 = bpy.props.BoolProperty()

    @classmethod
    def poll(cls, context):
        """If this returns False, operator is greyed-out."""
        return context.selected_objects != []
    
    def check(self, context):
        """While this returns True, draw() is called continuously."""
        return True

    def execute(self, context):
        main(context)
        return {'FINISHED'}
    
    def draw(self, context):
        layout = self.layout
        layout.prop(self, "val1")
        
        if self.val1:
            box = layout.box()
            box.prop(self, "val2")
            box.prop(self, "val3")
            
    def invoke(self, context, event):
        return context.window_manager.invoke_props_dialog(self, width = 800)


def register():
    bpy.utils.register_class(SimpleOperator)
    bpy.utils.register_class(SimplePanel)


def unregister():
    bpy.utils.unregister_class(SimpleOperator)
    bpy.utils.unregister_class(SimplePanel)


if __name__ == "__main__":
    register()
@schlegelp schlegelp changed the title make popup windows dynamice make popup windows dynamic Jun 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant