Miscellanious questions - mainly: What can i do with my pyrcc5'ed .qrc-file

Heads up! You've already completed this tutorial.

MillaSense | 2021-01-19 17:13:30 UTC | #1

In your packaging "howto" (..tutorials/packaging-pyqt5-apps-fbs/):

from fbs_runtime.application_context.PyQt5 import ApplicationContext

class AppContext(ApplicationContext):

python
def __init__(self, *args, **kwargs):
    super().__init__(*args, **kwargs)

    self.window = Window()

def run(self):
    self.window.show()
    return self.app.exec_()

is this a typo? Shouldn't it be:

python
def __init__(self, *args, **kwargs):
    super().__init__(*args, **kwargs)

If not.. sorry, couldn't find the AppContent.

But my main-question would be this: ..well, of course i stumbled upon fbs because i was having trouble with pure pyinstaller and setting up a proper .spec-file. I built my layout with Qt-Designer, so i got a .qrc file that i converted with pyrcc5 to a *_rc.py-file.

The complete guide to packaging Python GUI applications with PyInstaller.
[[ discount.discount_pc ]]% OFF for the next [[ discount.duration ]] [[discount.description ]] with the code [[ discount.coupon_code ]]

Purchasing Power Parity

Developers in [[ country ]] get [[ discount.discount_pc ]]% OFF on all books & courses with code [[ discount.coupon_code ]]

Where do i have to put this? How can i import/call it? ..or isn't this possible at all?

Thanks for your time! Have a great one.. And enjoy baby-time! (..they won't be that sweet, when they go through puberty.. like mine. :rofl:)


martin | 2021-01-21 12:40:37 UTC | #2

Hi @MillaSense welcome to the forum!

Thanks for the correction, yes that's a typo -- it's fixed now.

For the .py file created using pyrcc5 you can just put this in the same folder as your main application and import it from there by name, e.g. if your file is named resources.py just do

python
import resources

Or if you're using relative imports

PyQt/PySide 1:1 Coaching with Martin Fitzpatrick — Get one on one help with your Python GUI projects. Working together with you I'll identify issues and suggest fixes, from bugs and usability to architecture and maintainability.

Book Now 60 mins ($195)

python
from . import resources

Just importing it will cause the resources to be added to the Qt resource system, you don't need to do anything with the imported object.

There is a bit more about using QRC files in the PyInstaller tutorial -- it should be applicable here. The bundled app will just contain the .py file, not the original .qrc but that's OK, it's not needed anymore. Not 100% sure how this plays with fbs own resource system etc. would be interested to hear about it if you get it working!


MillaSense | 2021-01-22 08:56:13 UTC | #3

Errr.. I see, know what you're talking about, but honestly..

Nope, didn't make it - made THAT mistake, i.e. i was using 3.9.1 (that isn't supported by fbs), tried it with 3.6.0 before you answered, what didn't work out - went back to pyinstaller via terminal (cmd), edited the .spec-file (of course forgot to include the *_rc.py-file, what took me two hours to find and include..) and finally got my executable.

Thanks for your efforts, Senior! Awesome website, will surely visit you from time to time.. (when i'm into Python.) Have a good one!


Create GUI Applications with Python & Qt6 by Martin Fitzpatrick — (PyQt6 Edition) The hands-on guide to making apps with Python — Over 10,000 copies sold!

More info Get the book

Well done, you've finished this tutorial! Mark As Complete
[[ user.completed.length ]] completed [[ user.streak+1 ]] day streak
Martin Fitzpatrick

Miscellanious questions - mainly: What can i do with my pyrcc5'ed .qrc-file was written by Martin Fitzpatrick .

Martin Fitzpatrick has been developing Python/Qt apps for 8 years. Building desktop applications to make data-analysis tools more user-friendly, Python was the obvious choice. Starting with Tk, later moving to wxWidgets and finally adopting PyQt. Martin founded PythonGUIs to provide easy to follow GUI programming tutorials to the Python community. He has written a number of popular https://www.martinfitzpatrick.com/browse/books/ on the subject.