0

I am working on a python GUI app with Qt5, in which I created a resource.qrc file with Qt Designer. But for the Qt Gui I am actually using a resource_rc.py, which is created by a script as described by the following answer:

https://stackoverflow.com/a/36673994/9620269

In this case I have to run the following script to create the file:

python -m PyQt5.pyrcc_main resource.qrc -o resource_rc.py

I would like to store all files in a remote repository to provide access to other people. In this case, I would like to provide a solution, so that it's not necessary for other user to start the script manually, if they start after pulling the repo the first time.

I tried to use the configuration option "Before Launch" in PyCharm, in order to start the above script with a *.bat but it didn't work in my case.

Question:

How can I directly run the resource creation script (see above) with Pycharm before launching the main python script of a Qt5 app?

Rene
  • 976
  • 1
  • 13
  • 25

1 Answers1

1

A possibility could be to use a try block where you import the resource file the first time, and call the pyrcc script in the except:

try:
    import resource_rc
except:
    from PyQt5 import pyrcc_main
    pyrcc_main.processResourceFile(['resource.qrc'], 'resource_rc.py', False)
    import resource_rc
Rene
  • 976
  • 1
  • 13
  • 25
musicamante
  • 41,230
  • 6
  • 33
  • 58