15. Interface and application programming

Group Page

For this week's assignement I created a Virtual Environment and a User Interface with QtDesigner.


These are the steps that I followed to make it possible:

  1. Downloaded and installed Python on my Windows computer.
  2. Created a new folder for this week's assignment.
  3. Created a virtual environment inside the project folder using:
    python -m venv venv
  4. Activated the virtual environment from the terminal using:
    venv\Scripts\activate
  5. Installed the libraries needed for the interface:
    pip install PyQt6 
    pip install pyserial
  6. Checked the installed libraries using:
    pip freeze
  7. Documented the required libraries in a requirements file:
    pip freeze > requirements.txt
  8. Opened Visual Studio Code to work on the project files.
  9. Downloaded and installed Qt Designer to create the interface visually.
  10. In Qt Designer, I selected Main Window and created a new interface.
  11. I selected and inserted the widgets needed for my interface.
  12. I previewed the interface using Ctrl + R.
  13. I saved the interface file inside my virtual environment folder as a .ui file.
  14. I transformed the interface file into a Python file using:
    pyuic6 -x interface.ui -o frontend.py
  15. I executed the interface from the terminal using:
    python frontend.py
  16. I renamed the objects in Qt Designer to make the code easier to understand and connect.
  17. I saved the updated interface again.
  18. I transformed the updated .ui file again with pyuic6 so the Python file included the latest changes.
  19. I created the functions to connect the objects and generate actions, placing them after def retranslateUi(self, MainWindow):.
  20. I tested the interface with the terminal's preview.
  21. I corrected the croped text lable and tested again.

Find the final python code here.

Some useful resources can be found here: https://github.com/Mozta/interfaces-fab-academy

Microcontroler connection

Once the interface was working on its own, I took the next step and added a connection to my previous weeks' circuit so that the LEDs turned on when the button "register" of the interface was pressed.


To do that, I uploaded this code to my circuit with Arduino IDE, made some changes to the python code and here is the result: