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"
3 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

build_resources.zip (574 Bytes)

Here’s an experimental PowerShell script using the pyside-uic support present in
Shotgun TK by default. The goals were to:

  • not install anything
  • ensure use of a compatible pyside-uic

One might think of this as a less “detail oriented” cousin of build_resources.sh :grinning:

Use at your own risk.

Here’s hoping it inspires the good folks on the Shotgun TK team to greater heights of Windows 10 compatibility!

8 Likes

Thank you for your script. It saved my day and gave me hope. I hope you are doing well wherever you are.

2 Likes

+1 thanks for that script!

1 Like

Hi, i know is a little bit late but here is my solution to compile the Qt ui for the apps:

I use git on my PC so i have the git bash so from there i run the command “sh build_resources.sh”,

there are this commands inside the script:

  • pyside-uic
  • pyside-rcc

the first one is located in the Scripts folder of python ** X: \ python27 \ Scripts ** so if you config environment variables with this path there is no problem here, the problem is the second file that is not in the same folder , this command is on ** X: \ Python27 \ Lib \ site-packages \ PySide ** so if we add the path to the environment variables all work fine.

by the way, i change the sed command too, just remove the -i parametter, now looks like this:

 sed -e "s / from PySide import / from tank.platform.qt import / g" -e "/ # Created: / d" $ UI_PYTHON_PATH / $ 3.py

this script works for me, hope it helps.

build_resources.zip (839 Bytes)

Python 2.7
Pyside (installed with pip)
Windows 10 x64
Shotgun desktop 1.6.1

3 Likes