Convert a PyQt ui file to a Python file on Linux
Unfortunately the study guide is based on Windows and not everything works the same way on Linux. The problem I had was not converting the .ui file as saved from Qt Designer to the .py file but with opening and running the application. The first conversion I did was straight from the guide as per below:
pyuic5 source.ui -o target.py
That converted the .ui file to a .py file but I could not run the application. Two things happened.
- Running (python target.py) failed and showed import errors. This was not explained in the study guide and I figured out I need to run it as (python3 target.py).
- Problem is that the above application opens and closes when running it as (python3 target.py). After a lot of research I found that the -x flag needs to be used when converting the .ui file to the .py file on Linux as per below.
pyuic5 -x source.ui -o target.py
I managed to open the GUI application after converting the PyQt file (.ui) to a Python file (.py) using the above -x flag before the .ui file.
The below video shows the steps in detail.