Py3 & QT 5.15 .UI to .PY file conversion issue

I’m wondering if anyone has developed a TK app under Py3 and QT 5.15 and run into the issue of converting the .UI (QT designer file) to the .PY file using pyside2-uic. The resulting .py file will import PySide using the wildcard (*) instead of QtCore and QtGui.

from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtWidgets import *

Previously, it would use: from PySide import QtCore, QtGui. I haven’t been able to find any flags pyside2-uic to control this behavior.

My understanding is that TKs wrapper around PySide is not compatible with wildcard importing like that.

Additionally, it seems like TK does not support QtUiTools.QUiLoader so you can’t load the .UI directly in your code.

I’m wondering if anyone has a solution for this? Many thanks!

Yes, you can do this:

import sgtk.platform.qt5 as PySide2
from PySide2.QtCore import *
2 Likes

Thanks Richardo! It pays off to ask, you saved me from a headache.

For future reference, you can directly load the UI file similarly:

import sgtk.platform.qt5 as PySide2
from PySide2.QtUiTools import QUiLoader

1 Like

It took me a while to figure out too haha.

1 Like