Jump to content

pyscripter

Members
  • Content Count

    920
  • Joined

  • Last visited

  • Days Won

    56

Everything posted by pyscripter

  1. 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.
  2. Is there another sqlite dll in your path?
  3. pyscripter

    First Python + DelphiVCL Program

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

    The Delphi 11.2 release thread

    Same here. 11.1 was better I think with respect to LSP.
  5. 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.
  6. pyscripter

    an error message in new version of PyEngine

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

    Lazarus/FPC support

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

    Lazarus/FPC support

    This is now fixed. @acalandCould you please report whether fpc MacOS works ok?
  9. 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.
  10. 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
  11. 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".
  12. 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.
  13. 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!
  14. 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?
  15. pyscripter

    The Delphi 11.2 release thread

    Yes indeed. Do you know how to IFDEF 11.2 vs 11.1?
  16. 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
  17. 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.
  18. 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.
  19. 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;
  20. 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.
  21. 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.
  22. 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.
  23. pyscripter

    Can't create TPythonEngine at run-time. Why??

    You are not calling PythonEngine1.Load. Demo34 shows how to load a python engine dynamically, but please note that this is very tricky and things can go wrong.
  24. pyscripter

    Python4Delphi demo33 (multithread) does not work

    Python4Delphi demo33 (multithread) does not work · Issue #373 · pyscripter/python4delphi (github.com) is now fixed.
  25. Please see these earlier posts on SynEdit history: SynEdit preferred version? - Delphi Third-Party - Delphi-PRAXiS [en] (delphipraxis.net) Turbo SynEdit & Font Ligatures - VCL - Delphi-PRAXiS [en] (delphipraxis.net) DirectWrite and Unicode support One of the major flaws of SynEdit was the poor handling of Unicode. A major update has been committed to the TurboPack fork, that employs DirectWrite for text painting and fixes Unicode support. SynEdit should now be on a par with, if not better than, the best editors around with respect to Unicode handling. For example: Chinese is properly spaced and surrogate pairs and color emojis are fully supported: Bidirectional text editing is fully supported as well: WordWrap has been re-written and is now based on DirectWrite as well. This last update also includes other enhancements as for example an option to alpha blend the selection, another option for selection to cover just selected text instead of full lines, as in VS code and other editors, and horizontal mouse wheel scrolling: Other recent improvements: The undo/redo system was buggy and a mess, getting in the way of implementing new features. I has been reimplemented from scratch. The gutter has been reimplemented from scratch and is now flexible and extensible. A track changes bar like in Visual Studio has been added and unlike Delphi's it saves and restores line state correctly on undo/redo. The code base has been refactored cleaned-up, and partially documented, yet, and despite of the new features, it is thousands of lines shorter than the original. But a lot more can be done in this area. See here for the full list of enhancements in the the TurboPack fork. Backward compatibility Turbopack Synedit remains compatible with earlier versions of Synedit, but you do need to reinstall Synedit, load forms that use SynEdit ignoring error messages and save them again for the new properties to take effect. The use of DirectWrite though means that Windows XP is no longer supported. The TurboPack SynEdit fork supports Delphi versions Berlin or later. Future plans The next big planned feature is multi-selection and multi-cursor editing. Support the project Most of the bugs remaining in the issue tracker are C++Builder related. Also, the C++ packages have not been updated yet. We are actively seeking contributions on the C++Builder side of things (package updates, bug fixes). Of course you can also support the project by submitting bug reports and pull requests. Or, by implementing new features (e.g. minimap, Sync Edit like in Delphi, Delphi or VS-code like templates etc.) Note: Many thanks to @MarkShark for his great contributions to the SynEdit project.
×