Jump to content

pyscripter

Members
  • Content Count

    785
  • Joined

  • Last visited

  • Days Won

    42

Posts posted by pyscripter


  1. 57 minutes ago, Anders Melander said:

    Yes but the topic isn't "stuff that scale nicely".

    IconFontsImageList is an Image list. Font Awesome and Segoe MDL2 Assets font are both image fonts.  They contain images that scale nicely.  Anyway...

     

    Happy holidays to everyone!


  2. 1 hour ago, Attila Kovacs said:

    Please forgive my naivety and let me ask, do companies really putting their valuable source codes on an online platform?

    The value of stealing commercial code is overstated. The whole Windows code base has been leaked if I remember well.   Any employee can steal the source code.  And I must say I trust Github abilities to protect the source code (and Google and Amazon) more than those of the IT departments of most companies.


    • You can only load one pythonxy.dll in the Delphi process, hence you can only have one PythonEngine in an application.
    • Look at Demo33 on how to use threads and/or multiple sub-interpreters without blocking the main thread.  But also note that you cannot bypass the python famous GIL (Global Interpreter Lock), so that only one python thread can be executing at the same time.
    • Under Tutorials/Webinar II look at PyVizSVG.dproj on how to generate svg files in python scripts and how to display them in Delphi,
    • The only way to really use multiple cores to generate the graphs is to use external processes.  (there is the mutliprocessing unit in python, but it would be easier just to start multiple python processes from Delphi).
    • Like 1

  3. 1 hour ago, IanH9999 said:

     

    I can see that the VarPyth.pas header states that that it allows you to use Python objects like COM automation objects, but I'm having trouble understanding the relationship between the two. For example, when calling BuiltInModule.setattr why do I need to pass a Variant rather than a PPyObject?

    The mechanism that Delphi uses to dispatch such calls does not support it.

     

    You need some consistency.  Either you use the low-level Python interface and PPyObjects or VarPyth and custom variants.  Although you can easily convert PPyObjects to Variants and back (VarPythonCreate, ExtractPythonObjectFrom), sticking to one of the two simplifies life.


  4. vars is a builtin function.  You can use

     

    BuiltinModule.vars to access it using VarPyth

     

    If you are on Delphi 10.3 or later you can write something like 

    for V in BuiltinModule.vars(anObject) do begin
      anAttr := BuiltInModule.getattr(anObject, V)
      Writeln(V, anAttr.__class__)
    end;

    assuming anObject is a Custom Variant pointing to the python object.  (out of memory and not tested)


  5. Have you  read https://github.com/pyscripter/python4delphi/wiki/MaskFPUExceptions?

    There is no need to activate the Anaconda environment.  Just read and follow https://github.com/pyscripter/python4delphi/wiki/FindingPython.

     

    Quote

    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.

     

    If you want to work with a specific Conda environment (not the main installation) then you need to specify it as the DLLPATH.

     


  6. This is an old thread.  However I have a question regarding Russell Libby's unit.

    Has anybody used/tested TPipeConsole?  

     

    TPipeConsole uses standard pipes (OpenStdPipes calls CreatePipe), but then uses PeekNamedPipe on theses pipes in ProcessPipe.  According to the documentation this is a blocking operation when used with anonymous pipes and the whole thing falls apart.  Question: is this the case - does PeekNamedPipe blocks with anonymous pipes or this is only an issue when multiple threads try to access the same pipe?

     

    See also https://devblogs.microsoft.com/oldnewthing/20110707-00/?p=10223 by Raymond Chen

     


  7. Wrapping third party components is no different to wrapping VCL controls.   Consider all the WrapDelphiXYZ units as demos on how to do that.

    - Please note that with EnhancedRTTI, the only thing that needs wrapping is events other than simple TNotifyEvent.  So the wrapping code would be minimal.

    - There is no special wrapping needed for DataModules (TComponent descendent).  Access to the Screen.DataModules property is already wrapped.

    - Data Access wrapping is provided by the WrapFireDAC unit

    - Demo 31 has extensive coverage of Forms (creation, subclassing etc.)

     


  8. After some investigation I have committed changes that eliminate the exceptions during library finalization.

    The comment above about hiding the form still stands.

     

    If the main form is closed with action caFree, all VCL does, is send a Quit message (i.e. does not hide or free the main form).  If the application is not terminated (as is the case when running in PyScripter) the form is not closed.   You need to hide it using f.Hide().  In PyScripter the python application is truly terminated when you reinitialize the interpreter or close down PyScripter.


  9. 43 minutes ago, Kas Ob. said:

    I version is 2.7 and it is not working, i am not expecting it to work.

    Python 2 support was dropped recently.  But you can use the last release with Python 2 support.

     

    The VCL code is executed in the main thread.  ExitThread and ExitProcess are called by python on shutdown.  After Run is executed control is passed back to python.  In a standalone run python would exit at that point.   When run inside an IDE things may be different since the IDE will terminate the python process when appropriate.


  10. 3 hours ago, Kas Ob. said:

    I can't run that demo as it complain about Python version,

        You only need to change the following two lines to match your python version:

     

        // Adapt to the desired python version - Will only work with this version
        gEngine.RegVersion := '3.8';
        gEngine.DllName := 'python38.dll';

    I am happy to evaluate PRs in relation to the termination issue.  As I said it does work well when you run the python script standalone (not from a python IDE)

     


  11. The application terminates fine when run from the command line.  You are right that when is run from PyScripter the form does not close.  I am not fully sure, but it may have to do with the fact that PyScripter prevents the script from terminating so that the state of the interpreter can be examined after running a script.

     

    However you can hide the form by adding f.Hide() as the last statement of the main procedure.

×