Reputation: 2219
Is it possible to retrieve the line number from a Python script that is being executed within a hosted IronPython environment? I would like to somehow highlight that line in an AvalonEdit control outside of the hosted environment (in the hosting application that is) while the script is being executed.
Upvotes: 1
Views: 705
Reputation: 2219
I've figured out, it is possible to get the line by simply giving the script engine a trace callback method and (maybe asynchronously) fire an appropriate event that accordingly refreshes a IBackgroundRenderer... well... it works.
strategyScriptEngine.SetTrace(IronPythonTraceBack);
strategyScriptEngine.Execute(script, strategyScope);
At some other place in the same class:
private static TracebackDelegate IronPythonTraceBack(TraceBackFrame frame, string result, object payload)
{
if (IronPythonExecutingLine != null) IronPythonExecutingLine((int)frame.f_lineno);
return IronPythonTraceBack;
}
Upvotes: 2