13

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?

Niall C.
  • 222

4 Answers4

13

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
Eric Carvalho
  • 55,453
0

Run 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

Keith OYS
  • 421
-1
  1. Install python3.
  2. Install sip.
  3. Install python3-pip.
  4. Run the command: pip3 install pyqt5
Eliah Kagan
  • 119,640
mayur
  • 1
-1

Well, I documented the steps for Installing pyqt5 with qt designer and code generation here: https://gist.github.com/ujjwal96/1dcd57542bdaf3c9d1b0dd526ccd44ff

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

Chai T. Rex
  • 5,323
Ujjwal
  • 99