Jump to content

pyscripter

Members
  • Content Count

    425
  • Joined

  • Last visited

  • Days Won

    18

Everything posted by pyscripter

  1. pyscripter

    PPyObject V's Variant

    The mechanism that Delphi uses to dispatch such calls does not support it. You need some consistency. Either you use the low-level Python interface and PPyObjects or VarPyth and custom variants. Although you can easily convert PPyObjects to Variants and back (VarPythonCreate, ExtractPythonObjectFrom), sticking to one of the two simplifies life.
  2. pyscripter

    vars function within Delphi

    vars is a builtin function. You can use BuiltinModule.vars to access it using VarPyth If you are on Delphi 10.3 or later you can write something like for V in BuiltinModule.vars(anObject) do begin anAttr := BuiltInModule.getattr(anObject, V) Writeln(V, anAttr.__class__) end; assuming anObject is a Custom Variant pointing to the python object. (out of memory and not tested)
  3. I guess everyone knows this already, but I did find this Stackoverflow answer surprising. Can you guess what is the message shown? function DoSomething(SomeBoolean: Boolean) : string; begin if SomeBoolean then Result := 'abc' end; procedure TForm1.Button1Click(Sender: TObject); var xx: string; begin xx := DoSomething(True); xx := DoSomething(False); ShowMessage(xx); end; Shouldn't the above deserve a compiler warning?
  4. pyscripter

    PyPy support

    No.
  5. pyscripter

    Finding Anaconda distributions of Python

    Have you read https://github.com/pyscripter/python4delphi/wiki/MaskFPUExceptions? There is no need to activate the Anaconda environment. Just read and follow https://github.com/pyscripter/python4delphi/wiki/FindingPython. If you want to work with a specific Conda environment (not the main installation) then you need to specify it as the DLLPATH.
  6. This is an old thread. However I have a question regarding Russell Libby's unit. Has anybody used/tested TPipeConsole? TPipeConsole uses standard pipes (OpenStdPipes calls CreatePipe), but then uses PeekNamedPipe on theses pipes in ProcessPipe. According to the documentation this is a blocking operation when used with anonymous pipes and the whole thing falls apart. Question: is this the case - does PeekNamedPipe blocks with anonymous pipes or this is only an issue when multiple threads try to access the same pipe? See also https://devblogs.microsoft.com/oldnewthing/20110707-00/?p=10223 by Raymond Chen
  7. pyscripter

    DelphiVCL: Fantastic! But there are some issues

    Wrapping third party components is no different to wrapping VCL controls. Consider all the WrapDelphiXYZ units as demos on how to do that. - Please note that with EnhancedRTTI, the only thing that needs wrapping is events other than simple TNotifyEvent. So the wrapping code would be minimal. - There is no special wrapping needed for DataModules (TComponent descendent). Access to the Screen.DataModules property is already wrapped. - Data Access wrapping is provided by the WrapFireDAC unit - Demo 31 has extensive coverage of Forms (creation, subclassing etc.)
  8. pyscripter

    DelphiVCL: Fantastic! But there are some issues

    After some investigation I have committed changes that eliminate the exceptions during library finalization. The comment above about hiding the form still stands. If the main form is closed with action caFree, all VCL does, is send a Quit message (i.e. does not hide or free the main form). If the application is not terminated (as is the case when running in PyScripter) the form is not closed. You need to hide it using f.Hide(). In PyScripter the python application is truly terminated when you reinitialize the interpreter or close down PyScripter.
  9. pyscripter

    DelphiVCL: Fantastic! But there are some issues

    Python 2 support was dropped recently. But you can use the last release with Python 2 support. The VCL code is executed in the main thread. ExitThread and ExitProcess are called by python on shutdown. After Run is executed control is passed back to python. In a standalone run python would exit at that point. When run inside an IDE things may be different since the IDE will terminate the python process when appropriate.
  10. pyscripter

    DelphiVCL: Fantastic! But there are some issues

    You only need to change the following two lines to match your python version: // Adapt to the desired python version - Will only work with this version gEngine.RegVersion := '3.8'; gEngine.DllName := 'python38.dll'; I am happy to evaluate PRs in relation to the termination issue. As I said it does work well when you run the python script standalone (not from a python IDE)
  11. pyscripter

    Using the New Edge browser control

    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.
  12. pyscripter

    DelphiVCL: Fantastic! But there are some issues

    The application terminates fine when run from the command line. You are right that when is run from PyScripter the form does not close. I am not fully sure, but it may have to do with the fact that PyScripter prevents the script from terminating so that the state of the interpreter can be examined after running a script. However you can hide the form by adding f.Hide() as the last statement of the main procedure.
  13. pyscripter

    DelphiVCL: Fantastic! But there are some issues

    Did you try handling the Form OnClose event or use Release instead of Close?
  14. pyscripter

    DelphiVCL: Fantastic! But there are some issues

    Please file appropriate bug reports and open PRs, On note regarding WrapDelphi: The WrapDelphiXYZ units were written before the enhanced RTTI was implemented. Nowadays you do not need to wrap enumerations sets and the like. Here is an example from WrapDelphi unit tests: type TFruit = (Apple, Banana, Orange); TFruits = set of TFruit; TTestRttiAccess = class private FFruit: TFruit; FFruits: TFruits; public FruitField :TFruit; FruitsField: TFruits; StringField: string; DoubleField: double; ObjectField: TObject; RecordField: TTestRecord; InterfaceField: ITestInterface; procedure BuyFruits(AFruits: TFruits); property Fruit: TFruit read FFruit write FFruit; property Fruits: TFruits read FFruits write FFruits; end; With the above declarations and if you Wrap a variable say test of type TTestRttiAccess you can write python code such as: test.Fruit = 'Apple' test.Fruits = ['Apple', 'Banana'] So there is no need to create special wrappers of enumerations and sets. The WrapDelphi unit tests are worth studying in some depth.
  15. pyscripter

    Subforum for Python4Delphi

    I would like to use the Delphi-Praxis Third-Party section as a support forum for Python4Delphi. Any idea how a subforum for Python4Delphi can be created?
  16. pyscripter

    Subforum for Python4Delphi

    @DanielCould you please create a subforum in the Third-Party section for Python4Delphi?
  17. pyscripter

    Looking for SVG support in Delphi?

    In an earlier thread I presented an Interface-based access to native Windows (Direct2D) SVG support for Delphi applications. This has now been integrated into the SVGIconImageList components by @Carlo Barazzetta. Carlo is a kind of master of ImageLists (among other things). Have a look at his IconFontsImageList for instance. His SVGIconImageList component was based on the work of Martin Walter who must be a great programmer. His SVG component covered almost every SVG element and was well structured and cleanly written. There were numerous bugs and issues though, which, to a large extent, were fixed over the last few weeks and the code was refactored and optimized. Finally, @Vincent Parrett contributed a virtual version of the Image List, mirroring Delphi's VirtualImageList. So in its current form the component features: An SVGImageCollection component that inherits from Delphi's CustomImageCollection and thus is compatible with VirtualImageList A choice of SVG engines: the pascal one based on Martin's work which is using GDI+ and the native Windows one which is using Direct2D. Other SVG engines can be plugged-in with minimum effort. Excellent design support with a nice and effective SVGImageCollection editor developed by Carlo and the built-in VirtualImageList editor. Support for changing the opacity and color of the SVGs including using GrayScale. If you adopt Material Design for example and you use VCL styles, you can adjust the icon color to the style. Compatibility with older Delphi versions going back to XE6. It is free and open-source Svgs are vastly superior to bitmaps because they are typically tiny text files and scale perfectly. So, you do not need to ship with your application multiple resolutions of your images to match the DPI of the monitors. And there is a vast number of free SVGs to cover most needs. IMHO the combination of SVGImageCollection with Delphi's VirtualImageList is the best available solution (commercial ones included) for building DPI-aware Windows applications. Give it a try.
  18. pyscripter

    Olevariant and memory leak

    No the performance issue was https://quality.embarcadero.com/browse/RSP-23095 also fixed as suggested. https://quality.embarcadero.com/browse/RSP-23093 was a memory leak issue. Please read the reports. In both issues the suggested solution was implemented.
  19. pyscripter

    Olevariant and memory leak

    Glad to hear that! So it must be https://quality.embarcadero.com/browse/RSP-23093 that was causing the issue.
  20. pyscripter

    Olevariant and memory leak

    function TObjSvr.ObjAddRef: Integer; begin OutputDebugString(PChar(Format('TObjSvr ($%08X) AddRef', [integer(Self)]))); end; function TObjSvr.ObjRelease: Integer; begin OutputDebugString(PChar(Format('TObjSvr ($%08X) Release', [integer(Self)]))); end; Υour are overriding ObjAddRef, ObjRelease, without calling the inherited method. and you expect to see no memory leaks?
  21. The first VCS I used a long-time ago were CVS and FreeVCS (anyone remembers that?). In the days of Google code, I became an SVN fan using TortoiseSVN. When Google Code shut down all projects moved to Github and converted to git. But, I was very reluctant to move to git and carried on using SVN to work with Git repositories. Soon, I realize this change-resisting approach was counter-productive. I then switched to TortoiseGit and never looked back. Having to fork a repository to submit a PR is rather cumbersome (I wish you could do that from a clone), but I do understand the reasons why this is so.
  22. pyscripter

    Using the New Edge browser control

    I have added a workaround for https://quality.embarcadero.com/browse/RSP-31170
  23. pyscripter

    Using the New Edge browser control

    Just reported two QA issues relevant if you are planning to use/deploy TEdgeBrowser: https://quality.embarcadero.com/browse/RSP-31163 https://quality.embarcadero.com/browse/RSP-31170
  24. pyscripter

    Olevariant and memory leak

    This one was fixed in 10.4 https://quality.embarcadero.com/browse/RSP-23093 @NamoRamanaYou should provide a simple test case that reproduces the issue. Otherwise we are all guessing and hand-waving.
  25. pyscripter

    TControl.SetParent

    TControl.SetParent contains the following code: if not (csLoading in ComponentState) and not (csDesigning in ComponentState) and not (csDestroying in ComponentState) and not (csFreeNotification in ComponentState) then begin if not (csDesigning in Parent.ComponentState) then ScaleForPPI(GetParentCurrentDpi); end; Apart from the fact that I would write the if condition as if [csLoading, csDesigning, csDestroying, csFreeNotification] * ComponentState = [] then does anyone have any idea why controls with csFreeNotification are not scaled? This makes writing per Monitor DPI aware applications much harder.
×