-
Content Count
1050 -
Joined
-
Last visited
-
Days Won
70
Everything posted by pyscripter
-
See MaskFPUExceptions · pyscripter/python4delphi Wiki (github.com)
-
Return list from Delphi to python using DelphiWrapper
pyscripter replied to hsauro's topic in Python4Delphi
Something like Module := Import(ModuleName) if Module.__dir__().Contains(FunctionName) then Module.FunctionName() -
Return list from Delphi to python using DelphiWrapper
pyscripter replied to hsauro's topic in Python4Delphi
Wrong assumption. You need to call Free on the Python side or free it from Delphi. You can examine the ownership of a Delphi object in Python using the __owned__ attribute. If __owned__ is true it will be freed automatically. When you wrap objects yourself using DelphiWrappper.Wrap, you can specify the ownership. But here you are returning the object as a function result and you cannot tell who owns the object. Objects returned as function results or by accessing properties are wrapped using Wrap(obj, soReference); -
Return list from Delphi to python using DelphiWrapper
pyscripter replied to hsauro's topic in Python4Delphi
Wrapping of TStrings is fully supported. You can easily turn it into a Python list if needed. Look at Demo 31, python function testTStrings. -
python4delphi Python4Delphi module and Wrapping VCL classes
pyscripter replied to shineworld's topic in Python4Delphi
The TPythonModule is for using Delphi stuff in python scripts. To get started, look at the tutorials and demos. -
One of the new features of Delphi 10.4 was the new TEdgeBrowser component. It is nice. However the downside is that certain steps are needed for the use and delployment of this component: Install Edge WebView2 package via GetIt. This places a Dll called WebView2Loader.dll in the redist directory of Embarcadero studio (one for win32, one for win64). The appropriate WebView2Loader.dll needs to be deployed alongside your executable. (about 300Kb). While developing you can add a post-build event to do that. Now the difficult one was that you had to replace the stable version of Edge, installed and managed by Windows, with the unstable one from the Canary Edge update channel (daily updates). Event if you did that in your own machine, few users would accept it. The new thing, that is not mentioned in the documentation, is that there is a better alternative to the third requirement. You can use the WebView2 Runtime installer which works independently from and does not interfere with your browser, and can be safely deployed in customer sites. Give it a try.
-
Check with https://my.embarcadero.com. If the upgrades are there then they are free.
-
You can use the MultiInstaller. python4delphi/Install at master · pyscripter/python4delphi (github.com)
-
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.
-
I used it a couple of times and it worked well as far as instrumental profilers go.
-
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.
-
'Floating point division by zero' when running script
pyscripter replied to a topic in Python4Delphi
P4D provides the MaskFPUExceptions function for that purpose. -
Your Delphi verion does not support COMMAND
pyscripter replied to TimCruise's topic in Python4Delphi
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)? -
Your Delphi verion does not support COMMAND
pyscripter replied to TimCruise's topic in Python4Delphi
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? -
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.
-
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.
-
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...
-
Interesting way to copy dynamic arrays.
pyscripter replied to pyscripter's topic in RTL and Delphi Object Pascal
Try to output a again at the end of your routine. -
Interesting way to copy dynamic arrays.
pyscripter replied to pyscripter's topic in RTL and Delphi Object Pascal
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,...) -
Interesting way to copy dynamic arrays.
pyscripter replied to pyscripter's topic in RTL and Delphi Object Pascal
In the use case I described you avoid copying until (if) it is needed. Agree. -
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.
-
@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!
-
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.
-
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]
-
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?