[PyQt] uic.loadUiType does not load external resources

Vader golem.md at gmail.com
Sun Oct 20 13:42:51 BST 2019


Hello, PyQT devs!

After creating a custom widget that uses external images (with QT Designer),
I've noticed that when I load it with uic.loadUiType, the external images
are not loaded. When I use uic.loadUI instead, everything is fine.
After a short investigation, I figured out that UIParser.parse is called
without the "basedir" argument there.

uic.loadUI -> DynamicUILoader.loadUI -> self.parse(filename,
resource_suffix, basedir)
vs
uic.loadUiType -> compiler.UICompiler().compileUi ->
self.parse(input_stream, resource_suffix) 

Apparently, loadUi takes into account the case where the input stream object
is a file. In that case, it extracts the file path and uses it as an
argument to "self.parse". Contrary, compileUi does nothing like this.
Changing the call to "self.parse" in the loadUiType sequence to use the
"basedir" in the same way it is used by DynamicUILoader fixes the problem.

Please, consider applying this fix in the next version of PyQT.
Thanks!



--
Sent from: http://python.6.x6.nabble.com/PyQt-f1792048.html


More information about the PyQt mailing list