Jump to content

pyscripter

Members
  • Content Count

    1019
  • Joined

  • Last visited

  • Days Won

    66

Everything posted by pyscripter

  1. pyscripter

    Can't load package Python$(Auto).bpl

    Check with https://my.embarcadero.com. If the upgrades are there then they are free.
  2. pyscripter

    Trouble installing Python4Delphi

    You can use the MultiInstaller. python4delphi/Install at master · pyscripter/python4delphi (github.com)
  3. pyscripter

    Delphi profiler

    Have a look at this: In addition to SAX parsers you may want to consider XmlLite. XMLLite is a good alternative to SAX on Windows. See the note about push and pull parsers. Similar speed and much easier to program with. And there is a Delphi wrapper (just a single unit to add to your project). In my experience XMLLite was very fast. Microsoft is using XMLLite to parse SVG files.
  4. pyscripter

    Profiler for Delphi

    I used it a couple of times and it worked well as far as instrumental profilers go.
  5. pyscripter

    OnMouseDown/Up events

    If you want this done, you may open an issue with this request at the P4D issue tracker, or even better contribute a Pull Request implementing the events you want.
  6. P4D provides the MaskFPUExceptions function for that purpose.
  7. pyscripter

    Your Delphi verion does not support COMMAND

    Do you mean that if you open just one package in Delphi it causes Delphi to freeze? Is it a specific package or any of the packages? Can you reproduce it with a different Delphi installation (possibly in a different computer)?
  8. pyscripter

    Your Delphi verion does not support COMMAND

    This is probably the result of an unstable Delphi installation. There are no similar issue reports in the P4D issue tracker. What happens if you open the packages one by one instead of opening the project group?
  9. pyscripter

    OnMouseDown/Up events

    The TMouseEvent is not handled currently by P4D. To see which events can be handled search the source code for "RegisterHandler". You could write some code to handle such events. Please see WrapDelphiEventHandlerTest under the Tests directory for how to do that and if you want submit a PR to add this to P4D.
  10. pyscripter

    Get the propt value of input()

    You cant't, at least not easily. The input function writes to stdout the message and then reads from stdin the input. The two operations are separate. You may be able to guess from what was written to sys.stdout last. But what you can do is overwrite builtins.input with your own function.
  11. I am sure this is well known but I recently discovered a new way to copy dynamic arrays: var A, B : TArray<Integer>; ... B = A; SetLength(B, Length(B)); ... Test procedure: procedure Test(); var A, B : TArray<Integer>; begin A := [1 , 2, 3]; B := A; SetLength(B, Length(B)); B[1] := 12; Assert(A[1] = 2); Assert(B[1] = 12); end; Of course Copy is simpler, but in my use case I did not want to create a copy unless it was necessary e.g. In one part of the code // create A SetLength(A, L); ... In another part of the code B = A // do stuff with B or store it as an object field If A is not recreated you save the copying operation. Not a big deal...
  12. pyscripter

    Interesting way to copy dynamic arrays.

    Try to output a again at the end of your routine.
  13. pyscripter

    Interesting way to copy dynamic arrays.

    B=A does not cost much B = Copy(A, 0) moves memory and has a cost. In my use case A may be recreated (maybe not). If it is not recreated then I save the moving of memory. If it is recreated B becomes a unique copy after SetLength(A,...)
  14. pyscripter

    Interesting way to copy dynamic arrays.

    In the use case I described you avoid copying until (if) it is needed. Agree.
  15. pyscripter

    GExperts 1.3.19 Alpha 2 for Delphi 11 Patch 2

    An alternative to the method Žarko Gajić described is the following code: function ScaleImageList(Source: TCustomImageList; M, D: Integer): TCustomImageList; const ANDbits: array[0..2*16-1] of Byte = ($FF,$FF, $FF,$FF, $FF,$FF, $FF,$FF, $FF,$FF, $FF,$FF, $FF,$FF, $FF,$FF, $FF,$FF, $FF,$FF, $FF,$FF, $FF,$FF, $FF,$FF, $FF,$FF, $FF,$FF, $FF,$FF); XORbits: array[0..2*16-1] of Byte = ($00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00); var I: integer; Icon: HIcon; begin Result := TCustomImageList.CreateSize(MulDiv(Source.Width, M, D), MulDiv(Source.Height, M, D)); if M = D then begin Result.Assign(Source); Exit; end; Result.ColorDepth := cd32Bit; Result.DrawingStyle := Source.DrawingStyle; Result.BkColor := Source.BkColor; Result.BlendColor := Source.BlendColor; for I := 0 to Source.Count-1 do begin Icon := ImageList_GetIcon(Source.Handle, I, LR_DEFAULTCOLOR); if Icon = 0 then begin Icon := CreateIcon(hInstance,16,16,1,1,@ANDbits,@XORbits); end; ImageList_AddIcon(Result.Handle, Icon); DestroyIcon(Icon); end; end; It is simpler and I think works better.
  16. pyscripter

    SynEdit bracket highlight

    @Anders Melander You are using an old version of SynEdit. The key difference is the calls to UnionRect in TCustomSynEdit.InvalidateLines. Please compare to the SynEdit master branch. The difference is subtle, but in effect in your version any character entry invalidates the whole Window and this why you PaintTransient works. UnionRect(fInvalidateRect, fInvalidateRect, rcInval) is not the same as UnionRect(fInvalidateRect, rcInval, fInvalidateRect)! when fInvalidateRect is empty!
  17. pyscripter

    SynEdit bracket highlight

    Another issue with your code is that since you are using TArray.BinarySearch your bracket array needs to be sorted. But OCSYMBOLS: Array[0..7] Of Char = ('(', ')', '{', '}', '[', ']', '<', '>'); is not.
  18. pyscripter

    SynEdit bracket highlight

    By the way in the code above: a := SynEdit1.RowColToCharIndex(bufcoord); followed by c := SynEdit1.Text[a]; in fact twice, is not efficient. You are better-off just using c := SynEdit1.Lines[bufcoord.Line][bufcoord.Char]
  19. pyscripter

    SynEdit bracket highlight

    Anders is probably not using TurboPack SynEdit. His version of SynEdit is not handling ttBefore painting and the only way this can work is if SynEdit invalidates everything every time a character is typed. Turbopack SynEdit painting has been optimized to avoid flicker, so his version of Bracket Highlighting will not work with Turbopack SynEdit. I have committed some changes to Turbopack SynEdit (see Matching brackets highlighting with PaintTransient handler error · Issue #110 · TurboPack/SynEdit (github.com)). Could you please try with the latest version and see whether it now works correctly?
  20. pyscripter

    Marshalling COM Objects

    By the way, this is a good way to expose Com objects to python without relying on PyWin32.
  21. pyscripter

    Marshalling COM Objects

    I think the above should work. Have you enabled the generation of RTTI in your project? Does adding {$M+} help like in: {$M+} ITestInterface = interface(IInterface) ['{AD50ADF2-2691-47CA-80AB-07AF1EDA8C89}'] procedure SetString(const S: string); function GetString: string; end; {$M-}
  22. pyscripter

    GExperts 1.3.19 Alpha 2 for Delphi 11 Patch 2

    Toolbar images are not scaled but otherwise looks good!
  23. pyscripter

    GExperts 1.3.19 Alpha 2 for Delphi 11 Patch 2

    I am afraid the download link does not work.
  24. pyscripter

    Marshalling COM Objects

    You can use TPyDelphiWrapper.WrapInterface to wrap interfaces. Have a look at Tests/WrapDelphiTest.pas to see how this works. Alternatively the PyWin32 python module has its own way of wrapping Com objects.
  25. Are you talking about code completion in the editor or the interpreter? If it is in the editor does it help to add you delphi module to Tools, Options, IDE Options, Code Competion, Special packages? You need to restart PyScripter or the Language server. The other thing you could is to create a stub file for your python extension module (see for instance PyScripter: Completion with python extension modules such as PyQt5 and Pandas).
×