caimaoy
caimaoy

Reputation: 1228

How to import resource file in PyQt and build with pyinstaller?

First of all, I have use Qt Designer to turn a picture into a .qrc file, Then I use pyrcc4 to turn this .qrc file into a .py resource.

pyrcc4 qrcfile.qrc -o pyfile.py

then import this .py file in my .py file. but after build with pyinstaller this resouce file does not work.

pyinstaller -F my_code.py

How to import resource file in PyQt and build with pyinstaller?

Upvotes: 0

Views: 3012

Answers (1)

caimaoy
caimaoy

Reputation: 1228

see this answer

QRC file is an XML file that looks like below:

<RCC>
  <qresource prefix="/images">
    <file alias='filename.jpg'>images/filename.jpg</file>
  </qresource>
</RCC>

use it in .py file should be like this:

pixmap = QPixMap(':/images/filename.jpg')

Upvotes: 1

Related Questions