Skip to content

Developer Notes: GUI building with PyQt5

Rob Campbell edited this page Jun 19, 2019 · 4 revisions

The Lasagna GUI is built using PyQt5. The GUI is constructed using Qt Designer. This produces .ui files which can be converted to Python files using the pyuic5 command (see compileGUI.sh). For example, lasagna_mainWindow.py is generated by pyuic5 and builds the main GUI. You should not manually edit this file. Qt Designer also produces .qrc files that contain binary information for things like icons. This is also converted to a .py file.

Getting started with PyQt5

At the time of writing, you can head to fman.io to download a standalone version of Qt Designer and access an introductory tutorial. Another good tutorial source is zetcode.com. This official page should also help to get you started. Depending on what you're trying to achieve, you may need to get familiar with the reference pages for Qt, which are written for C but you can figure out how to interpret them for Python with a little experience.

The main thing you need to know with Qt Designer, is that you should name your GUI elements with sensible names using the objectName property in the Property Editor window. It is with these names that you will interact with the elements later in Python. Follow naming conventions used elsewhere in Lasagna. e.g. name buttons SOMETHING_pushButton. The most important thing is that the name should reflect what sort of GUI element this is.

Useful links