Can a UI button be created from within the user code?

If so, could someone share a code snippet or point me to a reference?

Thanks!