Qt for Python (i.e. PySide2) was announced recently and got me interested in trying to use it to load up a UI file. If you don’t know, PyQt and PySide / PySide2 can use the Qt Creator application to create user interfaces using a drag-and-drop interface. This is actually very similar to the way you would create an interface using Visual Studio. Qt Creator / Designer will generate an XML file with a *.ui extension that you can then load inside of your PySide2 application (or PyQt).
Creating the User Interface
For this example, I opened up Qt Creator and went to File –> “New File or Project”. Then I chose the “Qt Widgets Application” choice. See screenshot below:
Then I opened up the mainwindow.ui that Qt Creator made for me. You can just double-click it or click on the Design button that should be on the left-hand side of the program. Here’s a screenshot that might help:
I added three widgets to my UI: