How to compile Qt ui and resource files on Windows

Hey there,
I’m currently trying to develop a custom app based upon tk-multi-starterapp.

Unfortunately I’m on a windows machine and can’t get the build_resource.sh working. Is there any equivalent for windows?
Also it looks like the script uses the PySide compilers and not the PySide2 ones. Are those interchangeable?

Hope someone can help me out here.

Cheerio,
Tony

2 Likes

Hi Tony,

I found this from an old support ticket. Hope it works for you.

you can manually do this with little effort.

From the resources folder in the tk-multi-starterapp you can run the commands:

> pyside-uic.exe --from-imports dialog.ui > ../python/app/ui/dialog.py
> pyside-rcc.exe resources.qrc > ../python/app/ui/resources_rc.py

(or similar) on your system. Then manually go into your python/app/ui/dialog.py and change this:

from PySide import QtCore, QtGui

to this:

from tank.platform.qt import QtCore, QtGui

and in python/app/ui/resources_rc.py change:

from PySide import QtCore

to

from tank.platform.qt import

If you can’t find pyside-uic.exe on your system, ensure your have instaled PySide and look in your Python installation’s Scripts\ directory or Lib\site-packages\PySide directory (eg. C:\Python27\Scripts\pyside-uic.exe or C:\Python27\Lib\site-packages\PySide\pyside-rcc.exe`)

Cheers

Loney

2 Likes

Hey I thought I should chime in here as well, since only last week I was dealing with a similar thing.

If your code is only run within a Toolkit environment, then you can rely on the following for both PySide and PySide2

from sgtk.platform.qt import QtGui, QtCore

Toolkit wraps PySide2 so that the interface is similar to PySide. For example, it moves the contents of QWdigets into QtGui.

Our build resources script usually have a line that replaces the from PySide ... with our own import, so that you don’t have to manually do it after each build:

Note if your building in Python 3 you will need to update this line:

To:

    build_qt "pyside-rcc -py3" "$1.qrc" "$1_rc"
2 Likes

Thanks for the replys!
I think the problem lay’s in the PySide installation on my windows machine
I got the resource compiler up an running but sill I get pyside-uic: command not found

I am trying to compile using Python 2.7.15 which is installed via conda. I also installed PySide via conda. I am able to find the pyside-rcc.exe however I’m missing somethink like pyside-uic.exe. I can only locate a pysideuic folder in my environments site-packages that is filled with python scripts but does not contain any executable.

Do you maybe know if I can also use PySide’s QtUiTools.QUiLoader to simply load in a .ui file from with the apps dialog.py? Or any other hints on where to find pyside-uic for windows?

1 Like

Yeah I think the loading of .ui files at runtime should be fine, though I seem to remember there were some draw backs to that approach, and I can’t clearly remember what they were. Possibly the inability to reload the ui file in the same session?

I’ve definitely had cases in the past where I couldn’t find either the uic or rcc files, but I don’t remember what my solution was.

2 Likes

Hm I see… well I am now compiling the ui files with the python module pysideuic which has a compileUi() method in place. Changed up the build_resource.sh to run a small python script that invokes this command when compiling the ui files. This works fine for me at the moment.

Still I think it’s strange that the PySide installation for windows comes with a compiled pyside-rcc binary but lacks the uic equivalent. ¯_(ツ)_/¯

2 Likes