Jump to content

pyscripter

Members
  • Content Count

    983
  • Joined

  • Last visited

  • Days Won

    62

Everything posted by pyscripter

  1. pyscripter

    PyScripter - Integration with LLM

    @Stéphane Wierzbicki PyScripter with LLM support was released. See LLM_Support · pyscripter/pyscripter Wiki (github.com) for details.
  2. pyscripter

    Owner receives only Delphi objects

    I don't this is going to work. You are going to have duplicates of what is supposed to be Singletons (WrapDelphi, PythonEngine). It may work with run-time packages, but you would have to put all run-time packages in the same folder as the pyd files.
  3. pyscripter

    PyInstaller

    Have you followed the instructions at DelphiVCL4Python/samples/Installer at main · Embarcadero/DelphiVCL4Python (github.com) for delphivcl DelphiFMX4Python/samples/Installer at main · Embarcadero/DelphiFMX4Python (github.com) for delphifmx
  4. pyscripter

    DelphiVCL4Python

    I have used Python for many many years and really like the language. However it is slow. Really slow. And it does not use those damn CPU cores in my computer. If you look at Python (created in 1989) and Ruby (created in 1993), they have a lot in common and the same limitations. Ruby is also quite nice and there was a lot of buzz around it about 10-15 years ago, but the slowness almost killed the interest in the language. On the other hand, and in a hard to explain way, Python flourished. In an irreversible way. It is now the main programming language in schools and universities, including computer science degrees. It is here to stay for many years to come. Of course you can make python faster (Cython, using optimized python extension modules, multiprocessing etc.), but it takes an effort. The focus of python development has been two areas: type safety (kind of odd for a dynamic language) execution speed The two at some point may converge. There are a few developments regarding speed that offer some hope; Per interpreter Gil introduced in Python 12 (see https://en.delphipraxis.net/topic/10372-true-thread-parallelism-with-p4d-and-python-12). This is only accessible in embedded Python, using the python API. There were proposals to make it accessible through the interpreter, but were rejected in favour of the following developments. Experimental Just-in-Time (JIT) Compilation introduced in the coming Python 3.13 (so far, the speed improvements are negligible) Free threaded python (GIL-free) also introduced in python 3.13. Sounds good but it is incompatible with the GIL-enabled version of python. Extension modules are also incompatible and the two versions will be available in parallel, which sounds messy.
  5. pyscripter

    Records as TDictionary keys

    Just keep in mind [RSP-43423] Using {$WEAKLINKRTTI ON} causes access violation on TList<T>.IndexOf method - Embarcadero Technologies, See also
  6. pyscripter

    VTK in DelphiVCL or DelphiFMX

    WrapDelphi now automatically exposes all events. However, there has been no release of delphivcl recently incorporating these changes. If you create a custom delphivcl using the latest sources you do not need your custom panel. Panel should expose the above events.
  7. pyscripter

    DelphiVCL4Python

    You don't need Parent = self. Otherwise that's the idea.
  8. pyscripter

    PyScripter - Integration with LLM

    Real soon!
  9. pyscripter

    DelphiVCL4Python

    You are posting on the General Help forum. Since your topic is related to P4D you will get a better response by posting such questions to the Python4Delphi forum. The pydfm file plays the role of the dfm file in delphi. The statement self.LoadProps(os.path.join(os.path.dirname(os.path.abspath(__file__)), "MainForm.pydfm")) creates the controls and loads the design properties. Have a look at the demo DelphiVCL4Python/samples/DesignExport/SampleForm/MainForm.py at main · Embarcadero/DelphiVCL4Python (github.com) After the call to LoadProps, you can modify the controls. For example: self.LoadProps(os.path.join(os.path.dirname(os.path.abspath(__file__)), "MainForm.pydfm")) self.Button1.Caption = 'New Caption' Will show Button1 with Caption = 'New Caption' You can assign python code to events (e.g self.Button1.OnClick = ) or customize the controls in any way you wish.
  10. pyscripter

    Delphi + Python

    A unique feature of PyScripter is that, when you run a script, the python process is kept alive at the end of the run. For example if you run the script: a = 1 after running you can still see the value of a in the variables window and you can print its value by typing "a" in the interpreter window. This also allows post-mortem debugging (Run, Post Mortem). In Visual Studio, the form is destroyed, because the python process ends. With PyScripter, you have to explicitly destroy the form. To emulate the behaviour of other IDE's you could do Run, Reinitialize Python Engine at the end of each run. There were multiple request of emulating the PyScripter way in other IDEs (e.g. Access python console and program variables after program finished running? – IDEs Support (IntelliJ Platform) | JetBrains or if you google "python see variables after running").
  11. pyscripter

    Delphi + Python

    Add f.Free() as the last statement of main() Then it should work as expected. Application.Free() instead of f.Free() should also work.
  12. pyscripter

    Python 3.7 embedded windows 11

    The latest version dropped support for python 3.7. Use a more recent version of python.
  13. pyscripter

    Threadvar "per object"

    Indeed: python4delphi/Source/PythonEngine.pas at master · pyscripter/python4delphi (github.com)
  14. In the attachment you can find a high-level interface-based encapsulation of the Direct2D SVG functionality. It allows you to parse SVG files and draw them to a GDI/GDI+ DC. Requires Windows 10 with Creators Update or later. Main form code to display SVG files: { TForm1 } procedure TForm1.FormCreate(Sender: TObject); begin fSVG := GetD2DSVGHandler.NewSvg; fSVG.LoadFromFile('..\..\browser.svg'); //fSVG.FixedColor := TAlphaColorRec.Red; //fSVG.Opacity := 0.5; fSVG.GrayScale := True; end; procedure TForm1.Paint; begin inherited; fSvg.PaintTo(Canvas.Handle, TRectF.Create(ClientRect), True); end; procedure TForm1.Resize; begin inherited; Invalidate; end; Features: Scale to any size Keep aspect ratio (optionally) Control opacity Recolor to any color Draw in gray scale Samples: The above in grayscale: Svg.zip
  15. What is the svg you are painting? Can you show the svg text? By the way you should be using the SvgIconImageList which includes the above work.
  16. pyscripter

    Python4Delphi in a thread

    Dealing with python threads and the Global Interpreter Lock (GIL) is quite tricky. You need to either: Understand and use correctly the python API Initialization, Finalization, and Threads — Python 3.12.3 documentation or Use the high-level encapsulation provided by P4D, following the instructions in https://github.com/pyscripter/python4delphi/wiki/PythonThreads religiously. Otherwise, things can very easily go wrong.
  17. pyscripter

    Python4Delphi in a thread

    Have you followed the instructions?
  18. pyscripter

    Python4Delphi in a thread

    Please do not insert such long pieces of code in your script. You could have added the project as an attachment. Please read the relevant info PythonThreads · pyscripter/python4delphi Wiki (github.com)
  19. pyscripter

    Gutter width in Delphi 12/12.1

    It is almost a show stopper for laptop screens. I wonder why it has not attracted more votes and the attention of Embarcadero.
  20. pyscripter

    Gutter width in Delphi 12/12.1

    Not sure. It looks worse in a high DPI monitor.
  21. pyscripter

    New ChatLLM application.

    The latter.
  22. You don't need to modify WrapDelphi. Just use the latest version. function TValueToPyObject(const Value: TValue; DelphiWrapper: TPyDelphiWrapper; out ErrMsg: string): PPyObject; begin if Value.IsEmpty then Result := GetPythonEngine.ReturnNone else case Value.Kind of tkClass: Result := DelphiWrapper.Wrap(Value.AsObject); tkClassRef: Result := DelphiWrapper.WrapClass(Value.AsClass); tkInterface: Result := DelphiWrapper.WrapInterface(Value); tkRecord{$IFDEF MANAGED_RECORD},tkMRecord{$ENDIF}: Result := DelphiWrapper.WrapRecord(Value); tkArray, tkDynArray: Result := DynArrayToPython(Value, DelphiWrapper, ErrMsg); tkPointer: if Value.IsType<PPyObject> then Result := Value.AsType<PPyObject> else begin Result := nil; ErrMsg := rs_ErrValueToPython; end; else Result := SimpleValueToPython(Value, ErrMsg); end; end;
  23. pyscripter

    LockBox 3 via GetIt broken since April 2024 Update

    Indeed, but Github repo owners can safeguard against that by adding a .gitattributes file.
  24. pyscripter

    LockBox 3 via GetIt broken since April 2024 Update

    This is a common problem with Delphi github repos: https://github.com/JAM-Software/Virtual-TreeView/issues/1151#issuecomment-1332032004 Virtual-TreeView/.gitattributes at master · JAM-Software/Virtual-TreeView (github.com)
  25. In an older post I showed how to patch a virtual/non virtual, public/private method. A recently came across an Vcl bug that requires patching a non-virtual constructor. Does anyone know how to do that?
×