API:CreateUIComponent

Allows you to dynamically create a UI Component (aka Widget)

Parameters

 * widgetName
 * String - the name of a widget element like "Frame", Button", etc.
 * frameName
 * String - the name you want to give to the created frame (can be "" if you don't want a global frame variable created)
 * parentFrameName
 * String - the name of a parent frame (use "UIParent" if you're not sure)
 * templateFrameName (optional)
 * String - the name of a virtual template frame, which your newly created frame will inherit from
 * layer (optional)
 * Integer - the layer number of the component, defaults to -1

Returns

 * frameObject
 * Table - a table representing the frame.

Example
Working code for this can be found in uipaneltemplates.lua.