How do I customize my own panel?

I watched a tutorial on how to customize your own panel tools. So I experimented and wrote a script to display every function I needed on a panel so that I would have quick access to.

I wanted more specific functions on the panel such as a commandButton to run a script. (the script’s name shown below is angle()) Is that possible?

Also can you create an input field on the panel for the variable1 (currently set on 0) that has an interval from 0 to 10?


Here’s a simple example:

import bpy

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

    var1 = bpy.props.IntProperty(default=3, min=0, max=10)

    def poll(cls, context):
        return context.object is not None

    def execute(self, context):
        context.object.location.z += self.var1 / 10
        return {'FINISHED'}
class HelloWorldPanel(bpy.types.Panel):
    """Creates a Panel in the Object properties window"""
    bl_label = "Hello World Panel"
    bl_idname = "OBJECT_PT_hello"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "object"

    def draw(self, context):
        layout = self.layout
        layout.prop(context.window_manager, 'simple_op_var1')
        props = layout.operator(SimpleOperator.bl_idname)
        props.var1 = context.window_manager.simple_op_var1

def register():
    bpy.types.WindowManager.simple_op_var1 = bpy.props.IntProperty(default=3, min=0, max=10)

def unregister():
    del bpy.types.WindowManager.simple_op_var1

if __name__ == "__main__":

Sorry, my attachment didn’t upload properly last time. So I re-attached it on this post now.

I uploaded a video (best watched at 720p) to make it more clear what my problem is. Your answer has helped me but I don’t know how I can implement it into my script.


GUI4.blend (601 KB)

you need two properties, an operator property (which won’t show in a panel by itself, it will in the redo panel however if your operator enables undo) and a global property (which can be added to a panel like layout.prop(…))

You find a good explanation and step-by-step guide here:

(operators and operator properties is what you really need to know about)

Not sure what you are trying to do, but are you aware of the 3d printing toolbox addon / mesh analysis?