Jump to content

pyscripter

Members
  • Content Count

    1050
  • Joined

  • Last visited

  • Days Won

    70

Everything posted by pyscripter

  1. Why are you making things complicated? Follow the KISS rule. Using threads in this way requires deep knowledge of the Python API and the complexities of GIL. If do have to use threads, please study Demo 11 and the related posts in this forum Showing results for 'Py_Begin_Allow_Threads'. - Delphi-PRAXiS [en] (delphipraxis.net)
  2. It does, but it is not a good idea and should be avoided. See demo34 for how it can work. This demonstrates also AutoLoad = False
  3. Set AutoLoad to False and call LoadDLL at Runtime (e.g. in your FormCreate).
  4. PythonHome needs to be set even for registered conda distributions See TPythonVersion.AssignTo(PythonEngine: TPersistent); in PythonVersions.pas about this is done. Note also that for conda distributions to work properly, you need to add Format('%s;%0:s\Library\bin;', [Version.InstallPath] to your Windows path if it is not there already.
  5. Is there another sqlite dll in your path?
  6. pyscripter

    First Python + DelphiVCL Program

    It is cross-platform. It supports all targets Delphi supports.
  7. pyscripter

    The Delphi 11.2 release thread

    Same here. 11.1 was better I think with respect to LSP.
  8. pyscripter

    Extremely slow

    In general, Python scripts run just as fast (or better just as slow) using P4D in Delphi, as they do using python.exe. You need to show what you are doing in that respect.
  9. pyscripter

    an error message in new version of PyEngine

    MaskFPUExceptions · pyscripter/python4delphi Wiki (github.com)
  10. pyscripter

    Lazarus/FPC support

    Python4Lazarus is a fork focusing on fpc support. It does not include the based on WrapDelphi, delphifmx, delphivcl stuff.
  11. pyscripter

    Lazarus/FPC support

    This is now fixed. @acalandCould you please report whether fpc MacOS works ok?
  12. pyscripter

    Returning lists from Python to Delphi

    Variants are converted to strings when shown in the debugger. It does not mean that they contain strings.
  13. pyscripter

    Returning lists from Python to Delphi

    No it does not. You get a tuple containing arrays of floating type values. Are you using VarPyth? Is layerOutputs a Variant? If yes then you can use: var arr:Variant := layerOutputs.GetItem(0); // the first item of the tupple (array). var value:Variant := arr.GetItem(0); //the first floating value of the array
  14. pyscripter

    The Delphi 11.2 release thread

    By the way and on record helpers, in my little program above, if you move the declaration var Rec: MyRec; to Unit 1, interestingly, the output is "Hi".
  15. pyscripter

    The Delphi 11.2 release thread

    The issue was in the following: procedure TRegExHelper.AddRawOptions(PCREOptions: Integer); begin with Self do FRegEx.SetAdditionalPCREOptions (PCREOptions); end; FRegEx is defined in System.RegularExpressions and the nearest helper was in that unit. By the way the issue is now fixed. Thanks for reporting it.
  16. pyscripter

    The Delphi 11.2 release thread

    Actually it is the other way round. From the docs: but "nearest scope" means closer to where the variable is declared. Just to prove: Project File: program Project1; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils, Unit1 in 'Unit1.pas'; type MyRecHelper2 = record helper for MyRec procedure SayHi; end; { MyClassHelper1 } procedure MyRecHelper2.SayHi; begin WriteLn('Hello!'); end; var Rec: MyRec; begin Rec.SayHi; ReadLn; end. Unit 1 unit Unit1; interface type MyRec = record end; MyRecHelper1 = record helper for MyRec procedure SayHi; end; implementation { MyClassHelper1 } procedure MyRecHelper1.SayHi; begin WriteLn('Hi!'); end; end. Output: Hello!
  17. pyscripter

    The Delphi 11.2 release thread

    What happens then in Delphi 11.2? Which record helper will be active? I thought you are not allowed to have two helpers for the same class in the same scope?
  18. pyscripter

    The Delphi 11.2 release thread

    Yes indeed. Do you know how to IFDEF 11.2 vs 11.1?
  19. pyscripter

    The Delphi 11.2 release thread

    Regular Expressions have been revamped. The following feature requests have been implemented: https://quality.embarcadero.com/browse/RSP-21733 https://quality.embarcadero.com/browse/RSP-22372 https://quality.embarcadero.com/browse/RSP-22381
  20. pyscripter

    The Delphi 11.2 release thread

    I am having issues upgrading to 11.2. I run the Web Installer keeping the registry options. It appears to be going smoothly , uninstalling the previous version, then showing a message "Installing Main Application files" and in a few seconds it stops with a message "installation finished". I can see the application files in the Programs directrory, it even installs a shortcut on the desktop. But at the end of the installation I can see a running process bds.exe, that does nothing. If I end the process and try to run Rad Studio from the shortcut the bds.exe process starts but nothing happens. I remember that with previous version upgrades it would ask me for personalities and download tons of stuff from the cloud. This time nothing of the sort. Any clues? Update: The issue was related to addins. After removing the references to Beyond Compare, Parnassus and Gexperts, bds.exe started and allowed me to select platforms. It is now downloading and installing OK. And it works well.
  21. This is a code fragment that shows you how to convert python strings to Delphi strings with PyArg_ParseTuple function ShowMessage_Wrapper(pself, args: PPyObject): PPyObject; cdecl; var LMsg: PAnsiChar; begin with GetPythonEngine do begin if PyArg_ParseTuple(args, 's:ShowMessage', @LMsg) <> 0 then begin ShowMessage(Utf8ToString(LMsg)); Result := GetPythonEngine.ReturnNone; end else Result := nil; end; end; Also have a look at the PyArg_ParseTuple documentation. Using such methods is the low level approach to exposing Delphi code to python. Please have a look at WrapDelphi demos and tutorials for a high-level approach that that does not require you to use PyArg_ParseTuple or worry about reference counting and the like.
  22. pyscripter

    How to execute function in Python script

    Something like: var SL := TStringList.Create; try SL.LoadFromFile('__main__.py'); GetPythonEngine.ExecStrings(SL); Mainmodule.run_settings(); finally SL.Free; end;
  23. pyscripter

    SynEdit with memory leak?

    You can use LockUndo to disable Undo altogether. LockUndo/UnlockUndo is also useful when you read a file or initially setup a text buffer. If the Undo buffer is not empty then you would want to call ClearUndo before or after.
  24. pyscripter

    SynEdit with memory leak?

    Assuming you are using the Turbopack Synedit: Changes to the text buffer are undoable. So just calling Delete does not clear all related memory. You need to do one of: call ClearUndo every now and then to release the undo/redo memory. Set MaxUndo to some number to limit the undoable actions. The default is 0 (unlimited undo/redo). call LockUndo/Unlock undo to prevent actions being added to the undo/redo stack (the most efficient). If you still get a memory overflow then this is a bug that you should report.
  25. pyscripter

    Flash when showing form with VCL Styles

    I had a similar issue. If I remember well, setting the ParentBackground property to true for all controls helped, although I see in the previous thread that @Uwe Raabe claimed the opposite. There was such an issue https://quality.embarcadero.com/browse/RSP-31158 that is supposed to be fixed in D11. See also the related issues to this one. See also TStyleManager.UseParentPaintBuffers introduced in D11. I have not tried it and there is limited documentation.
×