I found some tutorials online for earlier versions of Ubuntu but they didn't seem to work on Ubuntu 14.10; either that or I was doing it the wrong way.
I want to use Qt Designer to design a GUI, use PyQt to covert it to .py, then use it in Python.
What packages do I need to install to do this?
4 Answers
All the tools you need are included in Ubuntu repositories. You must install the package qtcreator, which has an integrated QtDesigner, and the package pyqt5-dev-tools, which provides pyuic5, a utility that generates Python code from .ui files.
sudo apt-get install qtcreator pyqt5-dev-tools 1Run these in a Terminal:
sudo apt-get install python3-pyqt5
sudo apt-get install qttools5-dev-tools
sudo apt-get install qtcreator pyqt5-dev-tools
Run PyQt5 Designer, located at:
/usr/bin/designer
Run PyQt5 User Interface Compiler (PYUIC5) to convert .ui to .py
pyuic5 gui.ui -o gui.py
Run PyQt5 Resource Compiler (PYRCC5) to convert .qrc to .py
pyrcc5 images.qrc -o images_rc.py
- Install
python3. - Install
sip. - Install
python3-pip. - Run the command:
pip3 install pyqt5
Well, I documented the steps for Installing pyqt5 with qt designer and code generation here:
With this you can generate the code from Qt Designer itself.
Installation
pip3 install --user pyqt5 sudo apt-get install python3-pyqt5 sudo apt-get install pyqt5-dev-tools sudo apt-get install qttools5-dev-tools Configuring to run from terminal
$ qtchooser -run-tool=designer -qt=5 OR
Write the following in /usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf
/usr/lib/x86_64-linux-gnu/qt5/bin /usr/lib/x86_64-linux-gnu Code Generation
Create uic.py file.
#!/usr/bin/python3 import subprocess import sys child = subprocess.Popen(['pyuic5' ,'-x',sys.argv[1]],stdout=subprocess.PIPE) print(str(child.communicate()[0],encoding='utf-8')) $ chmod +x uic.py Create a symlink:
$ sudo ln uic.py "/usr/lib/x86_64-linux-gnu/qt5/bin/uic" Desktop Entry
[Desktop Entry] Name=Qt5 Designer Icon=designer Exec=/usr/lib/x86_64-linux-gnu/qt5/bin/designer Type=Application Categories=Application Terminal=false StartupNotify=true Actions=NewWindow Name[en_US]=Qt5 Designer [Desktop Action NewWindow] Name=Open a New Window Exec=/usr/lib/x86_64-linux-gnu/qt5/bin/designer save in ~/.local/share/application with .desktop extension