generate an event or function callback when a stringproperty is changed via user interface I have defined a StringProperty as:
StrParents = StringProperty(default='-1 ',update= GetParent), 
and used prop to display the property in a panel as: 
layout.prop(item, 'StrParents', text='parents').

I would like now to make some actions (i.e: call a function X()) if the StringProperty was changed from inside the code. And doing another action (i.e:call a function Y()) if the StringProperty was changed from the user via the panel. 

How can I achieve such that requirement?
I suggest looking at the context properties, for instance in this example context.area.type.  If scene.x is changed in the console it prints CONSOLE, a panel in the properties panel PROPERTIES etc.  As a test, print the context.copy() dictionary to find what suits for your needs.

import bpy

from bpy.props import StringProperty

def goober(self, context):
    print(context.area.type)
    return None

bpy.types.Scene.x = StringProperty(update=goober)