MapInfo Pro Developers User Group

 View Only
  • 1.  Change URI path to custom path

    Posted 10-09-2022 21:16
    Hi All.

    I'm trying to build a python tool for MapInfo and wanted to use custom images for my buttons.

    I've assembled a .dll file (first time doing it so there's a chance it wasn't done correclty) for platform x64 and made sure all my images we're set up to Resources and Do Not Copy on their properties. 

    The python script runs without a problem, but the images still don't come through. I'm using the addinorigin option for the path and file:/// since it seems to help with the spaces in the folder path as seen here
    buttonWorkspace.LargeIcon = CommonUtil.path_to_uri("pack://addinorigin:,,,file:///myfolderpath/ImagesResources/ImagesResources.dll;component/Images/map_Location_Strategy_32x32.png") 

    Not sure what I'm doing wrong, any ideas where to look?

    ------------------------------
    Maria Sousa
    WOOLWORTHS GROUP LTD
    Bella Vista NSW
    ------------------------------


  • 2.  RE: Change URI path to custom path

    Employee
    Posted 10-10-2022 03:41
    Hi Maria

    Did you have a look at this post: Can I also use my own custom icons/images for the controls?

    And this post which was created as an answer to the one above: Using custom icons from a .NET Assembly

    ------------------------------
    Peter Horsbøll Møller
    Principal Presales Consultant | Distinguished Engineer
    Precisely | Trust in Data
    ------------------------------



  • 3.  RE: Change URI path to custom path

    Posted 10-10-2022 04:37
    Hi Peter.

    Yes I followed the instructions on that post :)

    ------------------------------
    Maria Sousa
    WOOLWORTHS GROUP LTD
    Bella Vista NSW
    ------------------------------



  • 4.  RE: Change URI path to custom path

    Employee
    Posted 10-11-2022 01:03
    Edited by Anshul Goel 10-11-2022 01:03
      |   view attached
    Hello Maria,
     I have attached one python sample with example on using Images from .Net resource assemblies. Example also has a .Net resource assembly project that you can re-use for your images.

    code snippet:

    buttonHelloRibbon.LargeIcon = CommonUtil.path_to_uri("pack://addinorigin:,,,/file:///{}/ImageResources.dll;component/Images/close16.png".format(dirname(__file__)))
    
    buttonHelloRibbon.SmallIcon = CommonUtil.path_to_uri("pack://addinorigin:,,,/file:///{}/ImageResources.dll;component/Images/close32.png".format(dirname(__file__)))​

    Thanks
    Anshul

    ------------------------------
    Anshul Goel
    Knowledge Community Shared Account
    Shelton CT
    ------------------------------

    Attachment(s)

    zip
    HelloPython.zip   25 KB 1 version


  • 5.  RE: Change URI path to custom path

    Posted 10-13-2022 01:56
    Hi Anshul.

    I tried your piece of code, but no luck.

    ------------------------------
    Maria Sousa
    WOOLWORTHS GROUP LTD
    Bella Vista NSW
    ------------------------------