Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by pyscripter

  1. pyscripter

    Enbedded editor, debugging, etc...

    Not quite. You can use PyScripter code as a basis for providing embedded IDE functionality, however that would be non-trivial.
  2. pyscripter

    Xdata Rest server request & Python4Delphi

    I said "after loading" loosely speaking and not "in the OnAfterLoad event". Indeed you can only call Py_Begin_Allow_Threads after the engine is initialized. I have not tested, but you can set AutoFinalize to False and in the OnBeforeUnload do Py_End_Allow_Threads; Finalize; Also probably, skipping the above when the application closes down may not be necessary.
  3. pyscripter

    Xdata Rest server request & Python4Delphi

    Of course it is. If another thread holds the lock, PyGILState_Ensure blocks until the GIL becomes available, i.e. the holding thread calls PyGILState_Release. If more than one threads are waiting for GIL then I think it is assigned of FCFS basis. The automatic switching that you described only applies to threads created with the threading code. All other threads need to get the GIL before executing python code and then release it. Yes you do need to call Py_Begin_Allow_Threads in the main thread. When the python DLL loads, the main thread owns the GIL and it needs to release it before other threads can execute python code.
  4. The OleSetClipboardData documentation claims that the Clipboard implements delayed rendering, meaning that it renders a given format of the IDataObject implementation, only when the format is actually requested. My DataObject implements CF_UNICODETEXT and CF_HTML formats. As soon as I call OleSetClipboardData both formats are rendered. Any idea why is that? How can one implement delayed (lazy) rendering of clipboard formats?
  5. pyscripter

    OleSetClipboardData and delayed rendering

    I am using OleSetClipboardData with a IDataObject. This does not have any other arguments. And I am not handling WM_RENDERFORMAT or WM_RENDERALLFORMATS. These messages are handled by the OLE clipboard.
  6. pyscripter

    OleSetClipboardData and delayed rendering

    Thanks @Anders Melander. It could be the Windows 10 multi-device clipboard that results in this, or else some formats like CF_UNICODETEXT are translated automatically say to CF_TEXT for compatibility with the OLE 1.0 Clipboard.
  7. This does not work in per-Monitor DPI-aware applications.
  8. pyscripter

    InputQuery texts

    There is a corresponding event OnReceiveUniData. Which is used is based on IO.UnicodeIO, which by default is true.
  9. pyscripter

    InputQuery texts

    function TPythonGUIInputOutput.ReceiveData : AnsiString; Var S : string; begin if Assigned( FOnReceiveData ) then Result := inherited ReceiveData else begin InputQuery( 'Query from Python', 'Enter text', S); Result := AnsiString(S); end; end; You can handle the OnReceiveData event and respond in whatever way you like.
  10. MahdiSafsafi/zControls: zControls (github.com)
  11. pyscripter


    Starting from Syndey update 2, I am experiencing the folowing: Open in the IDE packages with no LIBSUFFIX or a LIBSUFFIX different that auto. LIBSUFFIX 270 is added automatically and the package is named accordingly Open project options and remove the LIBSUFFIX has no effect. Next time you open the project options is back there. Removing the LIBSUFFIX directive from the package source also has no effect on the package name. It seems that the IDE is enforcing the LIBSUFFIX 270. I have not found a workaround. You can still compile the packages from the command-line though. Am I missing something?
  12. pyscripter


    YES INDEED. That explains the mystery. It almost drove me crazy.
  13. pyscripter


    32bit VCL Windows. I have the issue with both runtime and design time packages. Try to open for example the D10_4 packages of github.com/EtheaDev/SVGIconImageList
  14. pyscripter

    SetLength TBytes Memory Leak

    FYI Added stCleanRawStack JclStackTrackingOptions option that eliminates … · project-jedi/jcl@4867c10 (github.com)
  15. Not quite. WebAssembly (WASM in short) is a binary executable format supported by all major browsers. See WebAssembly. Various compilers of different programming languages produce WASM code. Fpc is already moving ahead with support for Webassembly target. See WebAssembly/Roadmap - Lazarus wiki (freepascal.org). Overall WebAssembly is an alternative to compilation to JS. .Net has already a WASM target they call Blazor.
  16. pyscripter

    Error 87: Could not open Dll "python38.dll"

    The DLLPath was always meant to be the full path to the DLL. If it worked it was by accident rather than by design. Why don't you just use: PythonEngine.DllPath := TPath.Combine(ExtractFilePath(Application.ExeName), 'Python') in the OnBeforeLoad event for instance?
  17. pyscripter

    Tutorials on Python-Lazarus

    Have a look at the Webinars at python4delphi/Tutorials at master · pyscripter/python4delphi (github.com), The Webinar II video covers the creation of extension modules. The demo code is for Delphi. Quite a bit of that can be easily adapted for Lazarus or you can use the Delphi Community edition.
  18. Mostly agree. The problem with TEdit is a Windows and not a Delphi one. Notepad and VSCode have similar issues. If you are not rendering text it probably does not matter. I got interested in this because SynEdit does not handle complex unicode characters well. Other scenarios for using libraries such as ICU include proper sorting of multi-lingual text, proper change of capitalization, string normalization etc. (I mean better in corner cases than what Windows provides and more compatible with Unicode standards),
  19. It appears that ICU is the way to go. ICU is now bunded in Windows, .NET 5 is based on ICU, also android Unicode and internationalization support | Android Developers and iOS ICU usage in Swift - Development / Standard Library - Swift Forums
  20. And attached here is a text element enumerator that handles 🤷🏽‍♀️ correctly using ICU. Note though that the Edit Box and the List Box do not display 🤷🏽‍♀️correctly (shown as two characters). The content of the EditBox is åá̂̃̄🤷🏽‍♀️ (copied and pasted here). EnumTextElements.pas
  21. I did say I did not test . One missing line now added to the code. (FStart := FEnd); Works as expected in: var TestString := 'å'+#$0061#$0301#$0302#$0303#$0304; for var S in TextElements(TestString) do Writeln(S); and yes it does not work as it should with complex emojis. Interestingly even VScode does not handle 🤷🏽‍♀️ correctly. Paste the symbol and then try to delete it with Backspace. It takes pressing backspace multiple time to actually delete this emoji.
  22. CharNext does handle surrogate pairs, diacritics and other multi-codepoint sequences reasonably well. Cleary it does not handle emojis well. Nor does any other Windows function that I know of. But I was mostly trying to show that doing the text enumeration is the easy part. The .NET 5 unicode support is based on the ICU library. See Globalization and ICU | Microsoft Docs for details. There is an ICU Delphi wrapper but it has not been updated for years. ICU has been included in the Windows Creators update. The dll names the the header files are listed here. It would be nice to have translations of the headers to pascal and even better some higher level wrappers.
  23. Here is an implementation of a TextElementEnumerator (not tested): Note that in Windows CharNext is the best but still not perfect way to get text elements. See What('s) a character! | The Old New Thing (microsoft.com) You should then be able to write code such as: for var Element in TextElements(MyString) do: interface type TTextElementEnumerator = record private FStart: PChar; FCurrent: string; public constructor Create(const AValue: string); function MoveNext: Boolean; inline; function GetCurrent: string; inline; property Current: string read GetCurrent; end; TTextElementEnumeratorHelper = record private FString: string; public constructor Create(const AValue: string); function GetEnumerator: TTextElementEnumerator; end; function TextElements(const AValue: string): TTextElementEnumeratorHelper; implementation {$REGION Text Element Enumberator} { TTextElementEnumerator } constructor TTextElementEnumerator.Create(const AValue: string); begin FStart := PWideChar(AValue); end; function TTextElementEnumerator.GetCurrent: string; begin Result := FCurrent; end; function TTextElementEnumerator.MoveNext: Boolean; Var FEnd : PWideChar; begin if FStart^ = #0 then Exit(False); FEnd := Windows.CharNext(FStart); SetString(FCurrent, FStart, FEnd - FStart); FStart := FEnd; Result := True; end; { TTextElementEnumeratorHelper } constructor TTextElementEnumeratorHelper.Create(const AValue: string); begin FString := AValue; end; function TTextElementEnumeratorHelper.GetEnumerator: TTextElementEnumerator; begin Result.Create(FString); end; function TextElements(const AValue: string): TTextElementEnumeratorHelper; begin Result.Create(AValue); end; {$ENDREGION}
  24. pyscripter

    Py4Delphi and Python's subprocess

    TPythonGUIInputOutput only captures output sent to to sys.stdout and sys.stderr. It will not capture the output generated by sub-processes and printed to the console. You can capture the output of sub-processes and make it available to Delphi or print it from the script that creates the sub-processes. See subprocess — Subprocess management — Python 3.9.2 documentation for details
  25. pyscripter

    Access Violation python39.dll

    Have you seen the last comment in AttributeError: partially initialized module 'cv2' has no attribute 'VideoCapture' · Issue #303 · pyscripter/python4delphi (github.com) I am not sure whether specifying the dependency with a manifest file as in P4DPython26 · pyscripter/python4delphi Wiki (github.com) might help. A minimal script reproducing the error would be a lot more helpful instead of your long python script.