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?

4 Answers 4

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
1
  • 2
    Small note for those that follow. The module is found by importing like import PyQt5 . Apr 12, 2016 at 16:28
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

-1
  1. Install python3.
  2. Install sip.
  3. Install python3-pip.
  4. Run the command: pip3 install pyqt5
3
  • is it pip or sip? Mar 25, 2017 at 6:02
  • 2
    @HafizShehbazAli It may be that sip-dev was intended instead of sip, but pip doesn't make sense here. The Python 3 version of the pip package manager is provided by the python3-pip package which is already separately listed. SIP is related to PyQt. mayur: Can you edit this to include an explanation of how to "install sip" and why? Nov 12, 2017 at 17:14
  • I dont think you can install pyqt5 using pip in case of ubuntu
    – S Andrew
    Oct 8, 2020 at 9:56
-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

2
  • where are you putting the uic.py file?
    – markling
    Apr 12, 2019 at 0:49
  • I don't think we can do pip3 install --user pyqt5 in ubuntu
    – S Andrew
    Oct 8, 2020 at 9:58

You must log in to answer this question.