Jump to content

pyscripter

Members
  • Content Count

    1019
  • Joined

  • Last visited

  • Days Won

    66

Posts posted by pyscripter


  1. Please post questions regarding P4D to the Third Party P4D support forum.

     

    What is this InitThread?

     

    Using python threads 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 the P4D forum Showing results for 'Py_Begin_Allow_Threads'. - Delphi-PRAXiS [en] (delphipraxis.net)  


  2. 5 hours ago, programmerdelphi2k said:

    here Ctrl+F works

    Which Delphi version?

    Which Windows version?

     

    Could you please try using the Delphi way?

    • Add   Vcl.HTMLHelpViewer to the dpr uses clause
    • Set Application.HelpFile = to your chm file
    • Use the Application Help commands to invoke help (e.g. Application.HelpShowTableOfContents. Application.HelpContext etc.)

  3. 20 minutes ago, programmerdelphi2k said:

    it would be because "Ctrl+F" is a "Search on Editor-code"?

    Thanks for responding.  No, it is not that.   I have tested with a new minimal app, just a form and a button to open the help file, and the issue still exists.  I think it used to work with earlier versions of Windows/Delphi.


  4. In my Delphi apps, I use the dated CHM Html Help format to provide user help.   When help is invoked from the Delphi app using the Application help commands, Ctrl+F to search within a help page does not work.  However, if open the same chm file outside the Delphi app, Ctrl+F works fine.  Any clues as to what causes this issue?

     

    Note: The Delphi app is compiled with Alexandria (v11) and I am testing on Windows 11. 


  5. 19 hours ago, Brian Evans said:

    PyScripter is opensource so you can read the code. A quick look seems to suggest it doesn't - it unloads a bunch of common .pyd that might be loaded.

    Indeed.  As I said it is not foolproof.  If you use a specific set of python modules, you can see in Delphi's debug mode which DLLs are loaded when your python scripts execute.  You can then write code to unload them after unloading python.   Failing to unload a DLL does not necessarily mean that there will be an issue next time you load python.   


  6. 8 hours ago, David Heffernan said:

    Has this changed?

    Unloading and reloading has always been possible with P4D, but quite tricky and not foolproof.  You need to manually unload the dll's loaded by imported modules and if you fail to do that it will fail.   PyScripter does that and allows you to change python version without exiting.

    • Like 1

  7. 17 hours ago, tomye said:

    as i said,  i set 

     

    TPythonThread.Py_Begin_Allow_Threads;

    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)  


  8. 16 hours ago, tomye said:

    the anaconda which i installed is 64-bit

    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.


  9. In general, Python scripts run just as fast (or better just as slow) using P4D in Delphi, as they do using python.exe.

    7 hours ago, RDAF said:

    or the mechanism that transfers variables between Python

    and Delphi

    You need to show what you are doing in that respect.


  10. On 9/28/2022 at 10:28 PM, acaland said:

    what is the difference between P4D and Python4Lazarus?

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


  11. 2 hours ago, BennieC said:

    @pyscripter

    I have used your structure but still Delphi insist on giving me strings instead of floating point values.

    image.png.b6cae72d144f79f4288f7f6bc2646a68.png

    Can I somehow force the variant conversion to take this as a float?  I have tried to assign the variant to single variable but have no luck.

    Regards

     

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


  12. 2 hours ago, BennieC said:

    Value: (array([[0.09, 0.03, 0.34...0.]]. dtype=float32), array([[0.06, 0.05, 0.67...0.]]. dtype=float32))

    Currently this is just returned as a value with name layerOutputs, but Delphi sees this as a character string

    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

     


  13. 6 minutes ago, Vincent Parrett said:

    If that were the case, then you wouln't need to change anything at all in SynEdit - but you do as it cannot see SetAdditionalPCREOptions.

    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.

    • Like 2
×