Jump to content

shineworld

Members
  • Content Count

    343
  • Joined

  • Last visited

  • Days Won

    4

Posts posted by shineworld


  1. Today I'm getting crazy with Delphi Refactor > Rename Field (CTRL + SHIFT + E).
    Also starting a new IDE with a dummy project of only one variable the rename field get me the error:
    image.thumb.png.00ba959666ba6e4511216da26f51d566.png

     

    I don't know because message is in Italian language, but refactor is completly unusable.

    It notice that interface {B53A87B3-C809-4390-9BE2-6F1C168CF41D} is not registered.

     

    Athens 12.2 Patch 2.

    Any idea about that ?

     

     


  2. Seems that Canvas object is not usable in DelphiFMX.

    c.BeginScene() does not works also passing (None, 0) or any other combination:

    import delphifmx as fmx
    img = fmx.Image(None)
    bmp = img.Bitmap
    print(f'Initial Image Width         : {img.Width}')
    print(f'Initial Image Height        : {img.Height}')
    print(f'Initial Image.Bitmap Width  : {img.Bitmap.Width}')
    print(f'Initial Image.Bitmap Height : {img.Bitmap.Height}')
    bmp.Width = 200
    bmp.Height = 200
    img.Width = bmp.Width
    img.Height = bmp.Height
    print(f'Actual Image Width          : {img.Width}')
    print(f'Actual Image Height         : {img.Height}')
    print(f'Actual Image.Bitmap Width   : {img.Bitmap.Width}')
    print(f'Actual Image.Bitmap Height  : {img.Bitmap.Height}')
    c = bmp.Canvas
    print(f'Canvas Width                : {c.Width}')
    print(f'Canvas Height               : {c.Height}')
    r = fmx.RectF(0.0, 0.0, 100.0, 100.0)
    c.BeginScene(None, 0)
    try:
        pass
        #c.FillText(r, 'hello', True, 1, [], 'Center', 'Center')
    finally:
        c.EndScene()
    *** Remote Interpreter Reinitialized ***
    Initial Image Width         : 50.0
    Initial Image Height        : 50.0
    Initial Image.Bitmap Width  : 0
    Initial Image.Bitmap Height : 0
    Actual Image Width          : 200.0
    Actual Image Height         : 200.0
    Actual Image.Bitmap Width   : 200
    Actual Image.Bitmap Height  : 200
    Canvas Width                : 200
    Canvas Height               : 200
    Traceback (most recent call last):
      File "D:\x\develop\qem\cnc_api_client_core_1\python\api_client_fmx_demo\test-001.py", line 30, in <module>
        c.BeginScene(None, 0)
    TypeError: "BeginScene" called with invalid arguments.
    Error: Expected and actual arguments are incompatible
    >>> 


     


  3. So far, when I wanted to add a new UI component to DelphiVCL, I always started from DelphiVCL source, added the new unit with classes and types, and created a “clone” of the package with the new functionality using that instead of DelphiVCL.

    It works but I would like to “not touch” the original version of DelphiVCL installed by PyPi but only create an extensive module (pyd) with only the new UI controls.

    At this point I don't know if this can be done.
    I still understand little about P4D but it seems to me that each new module requires a PyEngine which loads the python DLL and this is already instantiated by DelphiVCL and if I create a new package with my new module and controls I assume there will be conflicts.

    Is this a viable way ?
    Is there any way to reuse the egine already created by original DelphiVCL to use it in my custom PYD ?

     

    I thank in advance those who will help me to dispel these doubts.

    Best regards
    Silverio

     


  4. Hi all,
    I'm trying to convert an old DelphiVCL (python) application to DelphiFMX and I was not able to define the form title icon image.

    In Project Options I've set Icon resource, as I made with DelphiVCL version:
    image.thumb.png.6fe40a0dfc6d57d9a60cd544d306e00e.png


    But during the python run the icon is not visible:

    image.thumb.png.98c3609b0a37eb86bce8ea90fdb795e2.png

     

    I've searched for Icon property in TForm and TApplication but not available.
    There is a way ?

    Thank you in advance for any suggestion.
    Best regards.


  5. Hello everyone,
    after years I decided to migrate a big project from Sydney 10.4.2 to Athens 12.2 latest version.

    Most things went smoothly, others required some work in the code but it works fine.

    I am left with one problem and one solution to find.
    In Sydney the default font used was “Tahoma 8” and the entire software was reliant on it and its features, which must often take advantage of every available pixel in the screen.

    Now when I create a new form or frame or add an object, I always end up with “Segoe UI 9” as the default font which returns text that is wider in width and breaks the continuity of the existing form/frame hundreds for me.

    How can I make sure that the old “Tahoma 8” is used as the default font during development and execution ?
    Many controls have multiple fonts and it is nerve-wracking to have to go searching for each “Font” property within them to change them by hand each time.

     

    Thank you.

     


  6. My 2 cents.

    I have been working with Delphi since the first version, that is, forever.
    It is my main development tool and one thing I have learned over the years.

    Whatever version I patch or whatever it is, I first install it on a VM.
    I never use third-party packages that don't start from source (no pre-compiled BPLs).
    I install all packages from source (with obvious modifications if they give problems).

    When everything works and I can work a few hours on the VM without any hiccups,
    then I uninstall the package from the working PC, clean up all directories and files from the previous installation that were not removed during uninstall, and repeat the operations done on the VM.

    It's a lot of work but I don't immediately switch to a new version when it appears.
    I wait for the inevitable patched versions to come out so I don't waste hours and hours of work.

    With these operations the bugs and snags are kept to a minimum and you can work.

     


  7. 2 hours ago, Vincent Parrett said:

    A gross generalisation on their part. It's entirely possible to create large applications without using a single Enterprise/Archtect feature. 

    I have been using Delphi for our software since version 1.0 and the latest project exceeds 22 million lines of code,

    but I have never felt the need to have the Enterprise or Architect version.

     

    Software products are tied to hardware equipment and 99% of the time they are free so keeping a

    subscription alive for Enterprise/Architect would become too costly for a small company.

     

    A missed opportunity in my case, I am continuing with the Pro version.

     

    In any case, Delphi remains and will remain my favorite development tool.

     


  8. Something goes wrong with either links.

    Virustotal notice a malware in the home page:
    https://www.virustotal.com/gui/url/ed9d2c0aac2e802dc498bc8fc7e8eb6102005a3f87606340d6837a7969846413?nocache=1

    When I try to download the file, as in your previous image, Free Download manager refuse to start,
    then automatically begin the normal chrome download but a 99% downloading stops with message "file not available on the net".


    Changing https:// to http:// in https://asphyre.net/files/Afterwarp-SDK-v300.7z with Download manager the download start but 
    close to end of the download the HTTP 403 error appears.

    At this point I've asked to VirusTotal to refresh the virus check of Afterwarp-SDK-v3007.7z submitting the download link
    and it notice two positive for "asphyre.net/files/Afterwarp-SDK-v300.7z contiene malware of type Cloud Virus":
    https://www.virustotal.com/gui/url/7e3fa21609ded7e62223028b875f7eb8a497e08550d574c49430cd53896bd222?nocache=1


  9. You can "teach" chatgpt with tags to avoid to repeat same things, eg:

    to chatgpt > When I use tag #DCODE you have to create a clean Delphi code as in followed text description adding short comments which does not use capital letter, eg: // sort the list, etc etc etc.

    So you can ask:

    > #DCODE create an alphabetical acending and descending sort of a TList<string> object.

    • Like 1

  10. Hi all.
    I've to convert a Builder C++ code to Delphi which uses bitfiels in union and I don't know where to start and if it is possible:

    // define QCL data types
    typedef short   QCL_WORD;
    
    typedef union {
        QCL_WORD data;
        struct {
            QCL_WORD alarm_state            :1;                 // bus flags: alarm state
            QCL_WORD alignment_state        :1;                 // bus flags: alignment state
            QCL_WORD inversion_wait         :1;                 // bus flags: external synchronism - inversion wait
            QCL_WORD out_of_min_bound       :1;                 // bus flags: column position is out of minimum boundaries
            QCL_WORD out_of_max_bound       :1;                 // bus flags: column position is out of maximum boundaries
            QCL_WORD below_safety_height    :1;                 // bus flags: column position is below safety height
            QCL_WORD in_working_pos         :1;                 // bus flags: column position is in working position
            QCL_WORD locking_latch_state    :1;                 // bus flags: column position in locking latch state
            QCL_WORD battery_warning        :1;                 // bus flags: column in battery warning
            QCL_WORD battery_alarm          :1;                 // bus flags: column in battery alarm
            QCL_WORD evr_state              :1;                 // bus flags: column EVR state
            QCL_WORD load_weight_zone       :2;                 // bus flags: column in load weight zone
            QCL_WORD column_is_consistent   :1;                 // bus flags: column in load weight zone
            QCL_WORD lift_set_acquire_req   :1;                 // bus flags: columns lift set acquire request
            QCL_WORD movement_mode_absolute :1;                 // bus flags: column has movement mode absolute
        } fields;
    } t_bus_flags_w4;

    Thanks in advance for any suggestion.
    Best regards


  11. I found an oddity in the "state" field of the OnCustomDrawItem event.
    Basically instead of reporting the states of the VCL control passed by the related event all possible states are passed there:

    function CustomDrawStateToPython(const ACustomDrawState: TCustomDrawState): PPyObject;
    
      procedure Append(const AList: PPyObject; const AString: string);
      var
        LItem: PPyObject;
      begin
        with GetPythonEngine do begin
          LItem := PyUnicodeFromString(AString);
          PyList_Append(AList, LItem);
          Py_XDecRef(LItem);
        end;
      end;
    
    var
      LCompType: PTypeInfo;
      LMin: integer;
      LMax: integer;
      LState: integer;
    begin
      Result := GetPythonEngine().PyList_New(0);
      LCompType := GetTypeData(TypeInfo(TCustomDrawState)).CompType^;
      LMin := LCompType^.TypeData^.MinValue;
      LMax := LCompType^.TypeData^.MaxValue;
      for LState := LMin to LMax do
        Append(Result, GetEnumName(LCompType, LState)); // <-- all enums are always set to state python attribute
    end;

    In my TreeView, when a node is selected, I've to change to white the font color otherwise text is hard to be sight:
    image.thumb.png.4f623249eb2b007299f31bc261d8c9fe.png

     

    Either I completely misunderstood the functionality of that function or there was an oversight.

    Unfortunately Vcl.ComCtrls TCustomDrawItem is defined as a set with direct enumerators in the set so I didn't find

    a direct method to do:

    if CAST_TO_ENUM(LState) in TCustomDrawState then

    but with a forcing and a pointer you still get something working:

    function CustomDrawStateToPython(const ACustomDrawState: TCustomDrawState): PPyObject;
    
      procedure Append(const AList: PPyObject; const AString: string);
      var
        LItem: PPyObject;
      begin
        with GetPythonEngine do begin
          LItem := PyUnicodeFromString(AString);
          PyList_Append(AList, LItem);
          Py_XDecRef(LItem);
        end;
      end;
    
      function IsBitSet(Index: Integer; State: TCustomDrawState): Boolean;
      var
        P: PByte;
      begin
        if (Index < 0) or (Index >= SizeOf(TCustomDrawState) * 8) then Exit(False);
        P := @State;
        Result := (P^ and (1 shl Index)) <> 0;
      end;
    
    var
      LCompType: PTypeInfo;
      LMin: integer;
      LMax: integer;
      LState: integer;
    begin
      Result := GetPythonEngine().PyList_New(0);
      LCompType := GetTypeData(TypeInfo(TCustomDrawState)).CompType^;
      LMin := LCompType^.TypeData^.MinValue;
      LMax := LCompType^.TypeData^.MaxValue;
      for LState := LMin to LMax do
      begin
        if IsBitSet(LState, ACustomDrawState) then
          Append(Result, GetEnumName(LCompType, LState));
      end;
    end;

    I'm not so smart in these things so if some Delphi guru has a better solution I'm ready to fix the code.

    Best regards.


  12. I need some help from Python + DelphiVCL guru.

    Some time ago I've made a new DelphiVCL control to use VTK with Python + VCL + VTK.
    To do that I've modified the Embarcadero's DelphiVCL package to add new control, called new library as cnc_vision_vcl

    to not override already installad DelphiVCL library and all worked fine.

     

    But I don't want to have a custom DelphiVCL and so I've tried to move the component in a delphivcl_ext project and

    at now same code does not work.

    What I've to in native Delphivcl code (which works)

    1. Create a clone of DelphiVCL projects as cnc_vision_vcl.
    2. Created new component WrapExtVTK.pas (attached).
    3. Modified source\vcl\WrapVclControls to import new unit:
      uses
        WrapDelphiTypes,
        WrapDelphiClasses,
        WrapDelphiWindows,
        WrapDelphiDataBind,
        WrapActions,
        WrapVclImgList,
        WrapVclControls,
        WrapVclGraphics,
        WrapVclForms,
        WrapVclActnList,
        WrapVclMenus,
        WrapVclStdCtrls,
        WrapVclComCtrls,
        WrapVclExtCtrls,
        WrapVclButtons,
        WrapVclGrids,
        WrapVclSamplesSpin,
        WrapVclWinXCtrls,
        WrapVclThemes,
        WrapVclDialogs,
        WrapVclMedia,
        WrapExtVTK;    // <--- new unit

       

    4. Compiled and used new cnc_vision_vcl.pyd file

    5. In the cnc_vision_vcl a zip with working test

       

    All work fine but I want to move component in an "ext"tra package to leave untouched original delphivcl,
    so I've created a clean project which add almost the same code but when I try to create the VTKPanel
    object I obtains: 

    self.vtk_panel = VTKPanel(self)
                         ^^^^^^^^^^^^^^
    AttributeError: Owner receives only Delphi objects

    In next chat the zip of entire project because I've reached post limits.



     

    WrapExtVTK.pas

    cnc_vision_vcl.zip


  13. Everything described by pyscripter is pure truth.
    I came to Python because of the need to use OpenCV with Delphi in analyzing frames from camera.
    There are a couple of wrapper libraries for OpenCV, but when I tried them they were more pains than joys.
    I then learned about DelphiVCL for python and that fixed the damaging issue of a good UI in Python.
    The whole phase of capturing frames from IP camera via Python was a bloodbath, too slow and blocking, even using in threads that are not parallel anyway.
    But Python4Delphi gave me the ability to "move" the heavy, parallel processing into Delphi threads.
    So I moved the camera communication and frame retrieval into a Delphi class using threads and Indy then exported to Python with P4D, quietly getting the required 30fps.
    I was then free to use the full power of OpenCV + Skia 4 Python + DelphiVCL + Cython to get a really high performance image processing framework. 

    Yes python can be fast if you roll with it.
    Obviously doing everything native in Delphi would be another thing...but it is known that importing libraries written in C++ is still impossible, except in rare cases where someone creates a wrapper in C with undoubted complexity of use.

     


  14. You can greatly improve the speed of a python script
    by passing it through Cython and obtaining compiled pyd (windows dll) or .so (linux library) output modules that can then be imported without any modification into the original code.

    I use Cython a lot.
    At the end of a project, through a script, I "cython" all the .py modules to get a version
    more performant and difficult to reverse engineer.

    In the middle Cython convert .py to .c and compile to pyd using MSCV or any other C++ compiler.


  15. 11 minutes ago, pyscripter said:

    WrapDelphi now automatically exposes all events.   However, there has been no release of delphivcl recently incorporating these changes.

    OK, I can understand the reasons for this.

    In my suite I will deploy a custom delphivcl renamed with a different name to avoid any collision with the native version of Embarcadero and installed in python as an offline whl package.

    The important thing for me was the ability to REMOVE the use of QT and be able to use the VTK 3D management package.
    At 90% I only program with Delphi, and Python + DelphiVCL + VTK is only for me to create support and research programs.

    At the end of it all I posted my solution so if anyone else finds themselves in need of using DelphiVCL + VTK they have a starting point for doing so.

    • Like 1
×