[PyQt] Confusion about load.uic() and import regarding pyinstaller

Hans Jörg Maurer hjm at pmeonline.net
Sun Mar 10 14:42:42 GMT 2019

@michael h @Barry:
Thanks. But indeed you have to decide which way to go. In the meantime
I found a workaround:
The directory of the ui - File must be include in the
pyprogramfile.spec as pathex=nameofui.ui or as hiddenimport on the
command line of pyinstaller.

Nethertheless it is confusing that there are different behaviors if a
ui is loaded as file or imported. In my opinion there should be no
difference. Maybe there are more troublemakers...


Both did run, but if I use the import and set e.g.
"self.ui.setWindowTitle('Do not read my title')" the app crashes with
"AttributeError: 'Ui_MainWindow' object has no attribute
'setWindowTitle'" I don't understand the reason and in addition I have
no idea how to solve this. Further ith hangs on 

 widgetList = self.ui.findChildren (QPushButton)
AttributeError: 'Ui_MainWindow' object has no attribute 'findChildren'

The idea behind was that I compile the ui before I run pyinstaller to
avoid problems at runtime.

You need to call self.setWindowTitle or self.findChildren. Those are
methods on QMainWindow.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20190310/b209792e/attachment.html>

More information about the PyQt mailing list