Jump to content

pyscripter

Members
  • Content Count

    1020
  • Joined

  • Last visited

  • Days Won

    66

Posts posted by pyscripter


  1. When you run as a service the registry information is not available.  You need to do something like:

    procedure TService1.CreatePyEngine;
    begin
      PythonEngine := TPythonEngine.Create(nil);
      PythonEngine.Name := 'PythonEngine';
      PythonEngine.DLLName := 'python313.dll';
      PythonEngine.DllPath := 'c:\pathtoyourpythonhome\';
      PythonEngine.RegVersion := '3.13';
      PythonEngine.UseLastKnownVersion := False;
      PythonEngine.FatalAbort := False;
      PythonEngine.FatalMsgDlg := False;
      PythonEngine.LoadDll;
    end;

    I have tested and it works.

    • Like 1

  2. I am also sceptical.  However, I see that in one of the most starred Github Delphi repos, danieleteti/delphimvcframework: DMVCFramework (for short) is a popular and powerful framework for WEB API in Delphi. Supports RESTful and JSON-RPC WEB APIs development., the IDE expert project generator, includes MSHeap by default.

     

    @Daniele TetiCould you please enlighten us as to what led you to this choice?

     

    By the way the RTL can be configured to use MSHeap, if compiled with the SIMPLEHEAP conditional define.  The downside is that ReportMemoryLeaksOnShutdown is not available with MSHeap.


  3. I very much like the "Filter Explicit properties" expert.

    However, in recent versions of Delphi (not sure when it started), the IDE inserts annoying DesignSize properties  that "pollute" the Dfm and the revision history.  It would be really nice if the expert was renamed "Filter DFM properties" and included the option of removing these DesignSize properties.

    • Like 3

  4. It is a bit tricky to run multiprocessing from P4D.

     

    For instance with Demo01:

    - Set VenvPythonExe to the appropriate python.exe path e.g. 'c:\python\python313\python.exe'

    - If you are printing from the processes and you want to see the output set UseWindowsConsole to True.  In your script there is no printing from the processes.

    - Add to the above script as first statement:

    __file__ = file_path

    - Save your script to that filepath

    - Run the demo and exec your script.

     

    image.thumb.png.78a6cddf37c1c94a91f58f15fadb5f99.png


  5. 2 hours ago, Ian Branch said:

    It is also a breaking change for all those 3rd Party libraries that you get their source code for and install by building their files.

    I have spent a couple of hours rebuilding libraries I had the source for that needed to be re-installed as, presumably, their existing .bpl/.dcp/.dcu files were no longer compatible.

    Also the existing installed plug-ins - GExperts, Eurekalog, MMX & cnWizards won't load.

    I rebuilt GExperts and is OK but I will have to wait for the other 3.

    Strange, since in my case both GExperts and MMX (v15.1.11) worked fine after installing the patch.   So did all components installed from source in Delphi 12.


  6. I have a user on Win7 reporting that the background color of VirtualTreeViews is black under any theme in Win7.  The app is compiled with Delphi 12 and the master branch of VT.   Earlier versions compiled with Delphi 11 and older version of VT appear to work fine.

     

     

    image.png.3638ec65f2e554bff4a25aa5ee258353.png

     

    Is anyone aware of Vcl Styles issues in Win7?

    Was there any changes in Delphi 12 or VirtualTreeView that may have had an impact on this?


  7. On 10/11/2024 at 3:11 AM, Vincent Parrett said:

    I wish the Rad Studio editor had this functionality

    Main Issues with the Delphi editor:

    • Unicode handling
      • The most serious issue with the Delphi editor IMHO is proper Unicode handling.  It has issues with surrogate pairs. combining characters etc.   Try for instance to paste ḱṷṓn to the editor.  Even wide Unicode characters have wrong spacing (e.g. 爾雅爾雅爾雅爾雅爾雅爾雅). Let alone of course the handling of emojis, bi-directional text etc. 
    • Missing standard code editor behaviour
    • The track changes bar does not play correctly with undo redo
    • Missing many nice-to-have features common in other code editors
      • Multi-caret editing
      • Move/Duplicate lines commands
      • HTML copy/paste to copy code with syntax highlighting to other apps
      • Alpha-blending of selection
      • OLE drag & drop
      • Support for font ligatures
      • etc.

    SynEdit now has first-class Unicode support based on DirectWrite, multi-caret editing, all other features from the list above and much more.  It is also very fast and responsive, but of course there is a lot of scope for performance optimizations.

     

    • Like 1
    • Thanks 3

  8. Please see the blog post and watch the videos!  Although the videos show PyScripter, the underlying editor control is SynEdit.

     

    Note:  Development of SynEdit has moved back to pyscripter/SynEdit: SynEdit is a syntax highlighting edit control, not based on the Windows common controls. (github.com) for the reasons explained here.  The multi-caret developments are in the multicaret branch, which will be merged to master after a period of testing.   It is quite solid, but if you would like to try and help iron out bugs, that would be much appreciated.

     

     

    • Like 11
    • Thanks 1

  9. 4 hours ago, Walid Alg said:

    Yes, I did. It didn’t work for me due to the absence of PyTorch, I don't know which library it is in, 

    It is part of

    Embarcadero/P4D-Data-Sciences: A collection of lightweight Python wrappers based on Python4Delphi simplifying Data Sciences development with Delphi (github.com)

     

    This is a similar project to Embarcadero/PythonPackages4Delphi: General collection of Python Packages wrapped for use in Delphi and C++Builder (github.com) and uses the same infrastructure.

     

    You need to have a similar setup for using moviePy to the PyTorch sample.

     

    These repos have been developed and are being maintained by Embarcadero.   I am not involved in them and have never used them.  You should direct your questions and issues to the respective repos.


  10. The recommended way to expose classes is to use  TPyClassWrapper<T: class>.

     

    If for example you have a class TMyClass you want to expose to python, you can use the above from unit wrappers as follows:

    PyDelphiWrapper1.RegisterDelphiWrapper(TPyClassWrapper<TMyClass>);

    or at runtime (e.g. inside the FormCreate handler:

    PyDelphiWrapper1.RegisterDelphiWrapper(TPyClassWrapper<TMyClass>).Initialize;
    

    If you want your class to capable of being instantiated from python then do:

        TMyClassWrapper = class(TPyClassWrapper<TMyClass>)
          constructor CreateWith(APythonType: TPythonType; args, kwds: PPyObject); overload; override;
        end;
    
        constuctor TMyClassWrapper.CreateWith(APythonType: TPythonType; args, kwds: PPyObject);
        begin
          Create(APythonType);
          DelphiObject := TMyClass.Create;
        end;

    and in the FormCreate handler:

        PyDelphiWrapper1.RegisterDelphiWrapper(TMyClassWrapper).Initialize;

    In your python script you can then create instances using the pythonic

    from delphi_module import MyClass
    obj = MyClass()

    With TStringList is a bit more complicated since the superclass TStrings has already been exposed.   To maintain the TStrings functionality you need to do the following:

    type
      TStringListWrapper = class(TPyDelphiStrings)
      private
        function GetDelphiObject: TStringList;
        procedure SetDelphiObject(const Value: TStringList);
      public
        constructor CreateWith(APythonType: TPythonType; args, kwds: PPyObject); overload; override;
        class function  DelphiObjectClass : TClass; override;
        class procedure RegisterMethods( PythonType : TPythonType ); override;
        class procedure RegisterGetSets( PythonType : TPythonType ); override;
        // Properties
        property DelphiObject: TStringList read GetDelphiObject write SetDelphiObject;
      end;
    
    class function TStringListWrapper.DelphiObjectClass: TClass;
    begin
      Result := TStringList;
    end;
    
    function TStringListWrapper.GetDelphiObject: TStringList;
    begin
      Result := inherited DelphiObject as TStringList;
    end;
    
    class procedure TStringListWrapper.RegisterGetSets(PythonType: TPythonType);
    begin
      // Do not call inherited
    end;
    
    class procedure TStringListWrapper.RegisterMethods(PythonType: TPythonType);
    begin
      // Do not call inherited
    end;
    
    procedure TStringListWrapper.SetDelphiObject(const Value: TStringList);
    begin
      inherited DelphiObject := Value;
    end;
    
    constructor TStringListWrapper.CreateWith(APythonType: TPythonType; args, kwds: PPyObject);
    begin
      Create(APythonType);
      DelphiObject := TStringList.Create;
    end;

    and in the FormCreate handler:

      PyDelphiWrapper1.RegisterDelphiWrapper(TStringListWrapper).Initialize;
    

    You can then use it in your python scripts as follows:

    from delphi_module import StringList
    sl = StringList()
    sl.Add("abc")
    print(sl[0])

     

     


  11. 17 minutes ago, Celebr0 said:

    I don’t understand how and where initialization is performed, you should know this

    You do not need to understand anything,  Just place a breakpoint on the Initialize statement and after the debugger stops there, keep pressing F7 (step in) until the error occurs.

     

    Anyway, I have downloaded the embedded version of python 3.12.6 64bits from  https://github.com/adang1345/PythonWin7, extracted the zip file in a directory 

    Quote

    c:\python-3.12.6-embed-amd64

    and used the following properties in PythonEngine:

     

      DllPath  C:\python-3.12.6-embed-amd64
      PythonEngine.RegVersion : 3.12
      PythonEngine.DllName : python312.dll
      PythonEngine.UseLastKnownVersion : False

     

    It seems to work fine on a Windows 11 machine.  You can try the same on your windows 7 machine.

     

×