How to activate an action with a button using python?
With this code you can trigger an action (adding a plane into Scene) with a Button in 'UI Panel' using Python. 

import bpy
from random import randint

class UIPanel(bpy.types.Panel):
    bl_label = "This is UI panel"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"

    def draw(self, context):
        self.layout.operator("object.plane", text='click to add', icon="BLENDER")

class OBJECT_OT_AddButton(bpy.types.Operator):
    bl_idname = "object.plane"
    bl_label = "Add a plane to the scene"

    def execute(self, context):
        print ("This is a test print statement")
        x = randint(0,10)
        y = randint(0,10)
        bpy.ops.mesh.primitive_plane_add(location=(x,y,0))
        return {'FINISHED'}

bpy.utils.register_module(__name__)