Jump to content

pyscripter

Members
  • Content Count

    779
  • Joined

  • Last visited

  • Days Won

    42

Everything posted by pyscripter

  1. pyscripter

    Howto use P4D Demo29 with PIL and OpenCV

    Also have a look at Demo 35 to see how you transfer arrays and array-like objects from Python to Delphi using the buffer protocol.
  2. pyscripter

    Howto use P4D Demo29 with PIL and OpenCV

    Add some error checking after the call. GetPythonEngine.CheckError; What is the error you are getting? It might help to post a minimal project.
  3. pyscripter

    Is there any edit/memo which allows multiselect?

    It is explained in the link to CudaText I gave above.
  4. pyscripter

    Is there any edit/memo which allows multiselect?

    All modern code editors have multi-select and multi-caret functionality (Visual Studio, VS-Code, Scintilla, Atom etc.). Also the freepascal CudaText. See CudaText - Free Pascal wiki for how it works. Very useful. I am currently working to add this to SynEdit.
  5. The sample code above uses VarPyth for high level access to python objects. MainModule is custom variant wrapping the __main__ python module. Unless you provide optional parameters to ExecStrings, the code is executed in the context of the __main__ module.
  6. How about? var SL := TStringList.Crete; try SL.LoadFromFile('example.py'); PyEngine.ExecStrings(SL); var Res := MainModule.DoExample('input'); finally SL.Free; end;
  7. pyscripter

    Problems while importing libraries with conda

    Are you calling SetPythonHome, as suggested in that page? Have you tried MaskFPUExceptions(True) instead? Is the Conda Library\bin subdirectory in the system path? If not try adding it.
  8. pyscripter

    Problems while importing libraries with conda

    Have you read FindingPython · pyscripter/python4delphi Wiki (github.com) regarding Conda? Is the DLLs subdirectory in the environment path?
  9. Please open an issue and describe the problem. Using SearchBuf should be OK.
  10. pyscripter

    D4P_export_demo

    Have seen https://github.com/Embarcadero/DelphiVCL4Python/issues/12?
  11. pyscripter

    Delphi4PythonExporter

    Please submit an issue to the relevant repo. I would expect that simply recompiling the component source with Delphi 12 should work.
  12. pyscripter

    TDirect2dCanvas Issues

    The Direct2D way of printing is to use the ID2D1PrintControl interface (Printing and command lists - Win32 apps | Microsoft Learn). You can look at SynEdit/Source/SynEditPrint.pas at master · pyscripter/SynEdit (github.com) for how this works.
  13. Features missing in the Delphi editor: Proper Unicode handling . It does not even support combining characters. Multi-cursor/selection editing Modification (track changes) bar that works with undo. Accessibility support Drag & drop editing triple and quadruple click support double/triple click and drag support Enhanced scroll bar as in VS Code ...
  14. pyscripter

    2D numpy Array back to delphi

    See The buffer protocol has been implemented · pyscripter/python4delphi · Discussion #443 (github.com) and demo 35.
  15. pyscripter

    Locking an Object

    Here is a lock-free implementation for your FHIROperationFactory function. var SingletonFHIROperationFactory : IFHIROperationFactory function FHIROperationFactory: IFHIROperationFactory; var LFHIROperationFactory: IFHIROperationFactory; begin if SingletonFHIROperationFactory = nil then begin LFHIROperationFactory := TFHIROperationFactory.Create; if InterlockedCompareExchangePointer(Pointer(SingletonFHIROperationFactory), Pointer(LFHIROperationFactory), nil) = nil then SingletonFHIROperationFactory._AddRef; end; Result := SingletonFHIROperationFactory; end; Delphi does something similar in some places.
  16. pyscripter

    Locking an Object

    Indeed. This is the whole purpose of locking.
  17. pyscripter

    DelphiVCL and asyncio

    The Embarcadero fork of P4D, is often ahead of the PyScripter repo, but it is currently behind. Its main focus is the generation of the delphivcl and delphifmx extension modules as well as Android support. The two repos are synced regularly. I am only responsible for the pyscripter P4D home repo. In most cases it does not matter which one you use.
  18. pyscripter

    DelphiVCL and asyncio

    Not too bad an idea. For instance this appears to run OK. import threading import time from delphivcl import * class DesktopView(Form): def __init__(self, owner): self.SetProps(Caption = "Welcome") # create and set update timer self.tmrUpdate = Timer(self) self.tmrUpdate.Enabled = False self.tmrUpdate.Interval = 1 self.tmrUpdate.OnTimer = self.__on_timer_update self.tmrUpdate.Enabled = True def __on_timer_update(self, sender): time.sleep(1) def app_main(): # initializes GUI Application Application.Initialize() Application.Title = "OPC UA Client Demo" # creates main application form app = DesktopView(Application) app.Show() FreeConsole() # enters in vcl main loop Application.Run() Application.Free() def inthread(): for i in range(20): print(i) time.sleep(1) if __name__ == "__main__": threading.Thread(target=inthread).start() threading.Thread(target=app_main).start() You could run the asyncio in a thread as in python - Running asyncio loop and tkinter gui - Stack Overflow. Also please submit an issue to the delphivcl project to expose the Application.OnIdle event. That would make the use of timer unnecessary.
  19. pyscripter

    Delphi 12 is available

    Like most new features and bug fixes, this introduces new bugs: https://quality.embarcadero.com/browse/RSP-43261 https://quality.embarcadero.com/browse/RSP-43263 Update I found a third even more serious issue related to the changes introduced for font scaling: https://quality.embarcadero.com/browse/RSP-43270
  20. pyscripter

    Delphi 12 is available

    The problem is that if you maintain open source components that support many versions of Delphi, this does not eliminate anything. It just adds another IFDEF in the code. Having said that, it is good to see it fixed.
  21. pyscripter

    Delphi 12 is available

    @Uwe RaabeUnfortunately though, your [RSP-35301] Option to design in Screen PPI but save in 96 PPI - Embarcadero Technologies is not, despite the many votes it got. And by the way thanks for your article. Highly recommended. Three of my reported issues were fixed and one more is wrongly marked as fixed (https://quality.embarcadero.com/browse/RSP-31137). But I have to agree with @David Heffernan that the list of new features is rather underwhelming, if you are not using C++ Builder. David what do you think of the change related to floating point exceptions?
  22. There have been a large number of new features and enhancements implemented in the P4D library recently . This discussion document provides an overview of these developments.
  23. In case you have not heard, Python 12 made a breakthrough towards running threads in parallel. For now, the feature is only available through the C-API and there are limitations. But still, the performance boost that comes from the exploitation of multiple cores makes this feature very desirable. P4D makes this feature very easily accessible by adding a new execution mode to TPythonThread. There is also a new demo (Demo 36) that shows how to run threads in parallel. If you are wondering about the performance boost, see the results below: Classic Subinterpreters: prime count 78498 prime count 78498 prime count 78498 prime count 78498 prime count 78498 Elapsed ms: 13695 Subinterpreters with own GIL: prime count 78498 prime count 78498 prime count 78498 prime count 78498 prime count 78498 Elapsed ms: 3482 You can find more details in this P4D announcement.
  24. pyscripter

    True thread parallelism with P4D and Python 12

    Let's not start language wars in this thread, which is about a significant development in Python 12 and how take advantage of it using P4D. P4D is about combining the strengths of python and Delphi, not choosing one versus the other.
×