Dynamic UI for custom implementation of IK

I’m trying to create a UI for a Python script of my own implementation of an IK constraint. I want to be able to add a list of rules for the IK constraint. This means that when an “add” button is pushed, the script would have to create some elements in the layout where properties for the new rule can be entered. I don’t know how I can modify the layout upon a push of a button. I’ve started to write code. I have an IKPanel class for the layout and the class IK_OT_new for the button to add a new rule. I don’t know how to access the layout member of the IKPanel class form the execute method of the IK_OT_new class. I suspect it would have to be from the ‘context’ argument, but I couldn’t find anything at https://docs.blender.org/api/blender_python_api_2_77_0/bpy.types.Context.html that would access the layout.

Also, I would need a different set of data for each pose bone. I have “row.prop(bpy.context.active_pose_bone,i[1])” in my IKPanel.draw member but I don’t know if that will result in each pose bone having its own set of data. That is, I have fields to enter the target bone, length of chain, etc., and I would need to be able to enter different values for different bones, so that if I select one bone and enter values, then select another bone and enter different values, and selected the first bone again, the values that I entered for the first bone would appear, instead of being overwritten by the values I entered for the second bone.

I also have ‘bl_context = “bone_constraint”’ but I don’t know if ‘bone_constraint’ is the right value. At https://docs.blender.org/api/blender_python_api_2_77_0/bpy.types.Panel.html it says that listing the possible values for bl_context are on the to-do list so I had to guess.

Here is my code so far (it won’t run; this is just a start; the last line is incomplete and thus a syntax error):

import bpy
from bpy.props import *

class IKPanel(bpy.types.Panel):
	bl_label = "IK Drivers"
	bl_space_type = "PROPERTIES"
	bl_region_type = "WINDOW"
	bl_context = "bone_constraint"

	def __init__(self):
		self.scn = bpy.context.scene
		self.xyz = []
		self.number = 0

	def draw(self,context):
		lay = self.layout
		row = lay.row(align=True)
		for i in [("Target","target"),("Bone","bone"),("Rotational Target","rot_target"),("Length","length"),("Iterations","iterations")]:
			row = lay.row(align=True)
			row.label(i[0])
			row.prop(bpy.context.active_pose_bone,i[1])
		row.operator("ik.new",text="Add Rule for IK")

class IK_OT_new(bpy.types.Operator):
	bl_idname = "ik.new"
	bl_label = "IK Rules"

	def execute(self,context):
		context.blend_data.