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.

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

More info Get the book

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

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!


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

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.