Jump to content

pyscripter

Members
  • Content Count

    777
  • Joined

  • Last visited

  • Days Won

    40

Everything posted by pyscripter

  1. VarPyth.Import just calls the Python function PyImport_Import which AFAIK does not modify files in any way.
  2. What does "loaded by Python4D" mean? What kind of character is this? Do you mean $A (LF)?
  3. The following statement compiles under Delphi 11 64 bits but produces an error in 32 bits. Assert.AreEqual(Rec.SubRecord.DoubleField, 3.14); [dcc32 Error] WrapDelphiTest.pas(357): E2532 Couldn't infer generic type argument from different argument types for method 'AreEqual' Here is the definition of Assert.AreEqual class procedure Assert.AreEqual<T>(const expected, actual: T; const message: string); Any idea why?
  4. pyscripter

    Is anybody but me using monitors with different scaling?

    I actually agree, but I wish this was implemented a few years back. Voted for that.
  5. pyscripter

    Is anybody but me using monitors with different scaling?

    With due respect, I think the bugs can be fixed without implementing your proposal. I have made a number of components (SpTBXLIB, zControls, VirtualExplorerTree, JvDocking, SynEdit, helped with VirtualTreeView) and applications per monitor DPI aware, so I am talking from experience.
  6. pyscripter

    Is anybody but me using monitors with different scaling?

    A few points related to this: It has been like this since High DPI support came to Delphi many versions back. Developers of High Dpi apps have been taking this into account. Changing this now will break many applications. PixelPerInch is not part of FontData. It is Delphi that sets it to Screen.PixelsPerInch when a font is created. Bear in mind that the same font can be used in different devices with different DPI Font.Size is a calculated property. It has always been. Font. Height is what is persisted. The correct way to set a Font to a GivenSize in a form is: Form.Font.Height := MultDiv(GivenSize, Form.CurrentPPI, 72) When a form is scaled it is the Font.Height that is scaled. Given that both Font.Height and Font.Size are integer properties, they will never be in perfect match. One of them will be off by a little. I think it is better to get the pixels right and get used to think in terms of Font.Height. Also bear in mind that the Windows Font dialog is not per monitor DPI aware and should not be used to set the Font size in per Monitor DPI aware applications. See High DPI Scaling Improvements for Desktop Applications and “Mixed Mode” DPI Scaling in the Windows 10 Anniversary Update (1607) - Windows Developer Blog for a way to work around this, but it is messy. It is better to just let the user select a font size from a drop down box and set the Font.Height as suggested above.
  7. pyscripter

    Utility to import/convert simple Python code

    Not that I know of.
  8. pyscripter

    Generic Type Inference

    @Uwe Raabe@Kas Ob. You are both right. double(3.14) resolves the problem. The documentation at Floating Point Constants - RAD Studio (embarcadero.com) states that "In the absence of any suffixes, floating-point constants are of type double. " This is irrespective of the compiler target. Is this a documentation error?
  9. pyscripter

    Tool to inspect properties at run-time?

    MahdiSafsafi/zControls: zControls (github.com)
  10. pyscripter

    New Community Edition

    In case you have not seen it: Delphi & C++Builder Community Editions Now Available in Version 10.4.2! (embarcadero.com)
  11. pyscripter

    Can not compile Python_D.dpk Ver. xe2

    The query is handled in xe2 bpl installation problem , need help · Issue #313 · pyscripter/python4delphi (github.com) Contributions from XE2 users are welcome.
  12. pyscripter

    Running Python scripts in threads

    Hard to answer this question in a meaningful way, since it depends a great deal on what you are trying to do. In general though: you can code performance critical computations in Delphi. See python4delphi/Tutorials/Webinar I at master · pyscripter/python4delphi (github.com) for an example of speeding up python code 60 times doing this. use python modules coded in C (or other compiled languages) that can spread computations to multiple cores.
  13. pyscripter

    Running Python scripts in threads

    class procedure TPythonThread.Py_Begin_Allow_Threads; You also need to call Py_End_Allow_Threads when all threads finish.
  14. pyscripter

    Running Python scripts in threads

    You need to call PyBeginAllowThreads in the main thread.
  15. pyscripter

    Unable to compile P4D with Delphi 10.4 for Linux64

    Thanks.. It is now fixed.
  16. pyscripter

    Unable to compile P4D with Delphi 10.4 for Linux64

    FProgramName should have a lenght of 0 (empty string) unless you call SetProgramName. Could you please check whether UCS4StringToUnicodeString fails with an empty string? UCS4String is defined as an array of UCS4Char. Could this be a fix? function TPythonEngine.GetProgramName: UnicodeString; begin {$IFDEF POSIX} if Length(FProgramName) = 0 then Result := '' else Result := UCS4StringToUnicodeString(FProgramName); {$ELSE} Result := FProgramName; {$ENDIF} end;
  17. pyscripter

    Unable to compile P4D with Delphi 10.4 for Linux64

    Do you mean? WL[Ι] := UnicodeStringToUCS4String(TempS); Changes committed.
  18. pyscripter

    Unable to compile P4D with Delphi 10.4 for Linux64

    There was a typo which is not fixed {$IFDEF POSIX} PWCharT = PUCS4Char; PPWCharT = PUCS4Char^; WCharTString = UCS4String; {$ELSE} Please try again with the latest. Please report back any further issues, since I have not tested with Linux recently.
  19. There are many Delphi units for doing that e.g. - JCL library in JclSysUtils Execute functions - JVCL JvCreateProcess component and many others
  20. 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.
  21. 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.
  22. 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.
  23. 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?
  24. 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.
×