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.

http://www.blendpolis.de/download/file.php?id=90674&mode=view

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?

[ATTACH]282709[/ATTACH]

Here’s a simple example:

import bpy


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


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


    @classmethod
    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.utils.register_module(__name__)
    bpy.types.WindowManager.simple_op_var1 = bpy.props.IntProperty(default=3, min=0, max=10)




def unregister():
    bpy.utils.unregister_module(__name__)
    del bpy.types.WindowManager.simple_op_var1




if __name__ == "__main__":
    register()

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

https://youtu.be/KE8yk-UZ_wQ

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.

Attachments

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:
http://www.blender.org/documentation/blender_python_api_2_69_8/info_tutorial_addon.html

(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?

http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.67/Print_Tools
http://wiki.blender.org/index.php/Doc:2.6/Manual/Modeling/Meshes/Mesh_Analysis