Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Image files not included in pysidedeploy build
Qt 6.11 is out! See what's new in the release blog

Image files not included in pysidedeploy build

Scheduled Pinned Locked Moved Unsolved Qt for Python
2 Posts 2 Posters 560 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Labeaoux
    wrote on last edited by Labeaoux
    #1

    I am building an application that relies on some images. I am packaging the application with the pysidedeploy tool. In my code I am actively changing the root application path to adjust for whether I am running locally or in the deployed application. However I am noticing that in my builds the MacOS folder in the .app Contents folder does not contain any of my .png files.

    For example:

    if getattr(sys, "frozen", False):
            application_path = sys._MEIPASS
        else:
            application_path = os.path.dirname(os.path.abspath(__file__))
    
        icon_path = os.path.join(application_path, "icons/1.png")
        if not os.path.exists(icon_path):
            print(f"Warning: Icon file not found at {icon_path}")
    

    yields a

    Warning: Icon file not found at /path/to/build/myApp.app/Contents/MacOS/icons/ooo.png
    

    I have attempted adding the image paths to my pyproject file:

    {
        "files": [
           ...
            "icons/1.png",
            "icons/2.png",
            ...
        ]
    }
    

    And also to my pysidedeploy.spec

    
    [files]
    include = 
    	icons/1.png,
    	icons/2.png,
    

    However still there are no png artifacts located anywhere in my build directory. How can this be done?

    1 Reply Last reply
    0
    • CristianMaureiraC Offline
      CristianMaureiraC Offline
      CristianMaureira
      wrote on last edited by
      #2

      For the .qrc approach to work, which is what we recommend, to do the following:

      If you have icons/ in the root of your project, then add to your .qrc file needs to have entries like: <file>icons/1.png</file>, and then when you generate the .py file out of it, you import it in the file you want to use, and refer to the files like :/icons/1.png.

      More information in https://doc.qt.io/qtforpython-6/tutorials/basictutorial/qrcfiles.html#tutorial-qrcfiles

      With that, pyside6-project will pick them automatically.

      The <name>.pyproject file is only a construct for QtCreator to open projects, and it's not related to pyside6-deploy

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved