Closed Uefi1 closed 3 months ago
Exec the script containing 'print( )' and use
property IO: TPythonInputOutput read FIO write FIO;
property RedirectIO: Boolean read FRedirectIO write FRedirectIO default True;
Exec the script containing 'print( )' and use
Thanks, I figured it out a little but it doesn't work (
function ExecPythonFile(const Filename):string;
var
FGILState: PyGILstate_STATE;
PythonInputOutput:TPythonGUIInputOutput;
begin
Result := '';
PythonInputOutput:=TPythonGUIInputOutput.Create(nil);
PythonEngine.IO:=PythonInputOutput;
Result:=PythonInputOutput.Output.Text;
FGILState := PythonEngine.PyGILState_Ensure;
try
PythonEngine.DoRedirectIO;
PythonEngine.ExecFile(Filename);
except
end;
PythonEngine.PyGILState_Release(FGILState);
PythonInputOutput.Free;
end;
Result:=PythonInputOutput.Output.Text; PythonEngine.DoRedirectIO
I never used these 2 methods. what I use:
I never used these 2 methods.
Sorry I don't understand your code a bit (
- I attach PythonIO to TPythonEngine.IO property
Still, I think that my last option should work, but I don’t understand why it doesn’t work ( Thank you very much for your help, of course, but you have some other language in which you write, so I don’t understand it yet
- Use support forum for answers to questions, not the Issue tracker. If you do it again I will blacklist you from this repo.
Hello, I think I did everything as you said, the output still doesn’t work (
var
PythonEngine: TPythonEngine;
PythonInputOutput:TPythonGUIInputOutput;
procedure InitPython;
begin
PythonEngine := TPythonEngine.Create(nil);
try
PythonInputOutput:=TPythonGUIInputOutput.Create(nil);
PythonInputOutput.DelayWrites:=True;
PythonEngine.InitThreads := True;
PythonEngine.UseLastKnownVersion := True;
PythonEngine.AutoLoad := False;
PythonEngine.AutoFinalize := False;
PythonEngine.AutoUnload := False;
PythonEngine.RedirectIO := True;
PythonEngine.IO:=PythonInputOutput;
PythonEngine.LoadDll;
TPythonThread.Py_Begin_Allow_Threads;
finally
end;
end;
function ExecPythonFile(const Filename:string):string;
var
FGILState: PyGILstate_STATE;
begin
Result := '';
FGILState := PythonEngine.PyGILState_Ensure;
try
PythonEngine.ExecFile(Filename);
except
end;
PythonEngine.PyGILState_Release(FGILState);
Result:=PythonInputOutput.Output.Text;
end;
Once again, the Issue tracker on GitHub exists for questions, ideas, feedback, tasks, or bugs for work on GitHub.: https://docs.github.com/en/issues/tracking-your-work-with-issues/about-issues
Why the hell should I register on forums with dubious content for each individual repository on Github, and what if the database is stolen on such a forum?
In general, the Python4Delphi BUG does not want to display data for any parameters or settings or assigned events onsenddata onreceivedata
Hello, how can I output the results to a string variable of a .py script running in a multi-threaded application ?