PyQt5 Tutorials
About Lesson

In this Python PyQt5 lesson we want to learn about Python PyQt5 MySQL Database Login App, before this we have learned how you can work with mysql database and pyqt5, we have talked about mysql database connection, inserting data and retrieving data from mysql database in Python PyQt5.

 

 

Now open your Qt Designer,  you can just write pyqt5designer in your terminal, after opening the Qt Designer you need to create Widget window. now we add widgets in Qt Designer.

  • Add an HBoxLayout in QHBoxLayout add a label and lineedit
  • Add another HBoxLayout, you need to also add a label and lineedit in this layout
  • Add a VBoxLayout, in this layout add a QLabel with a QPushButton
  • At the end click on the main window and select layout vertically for all widgets
  • Also you need to add a vertical spacer between the lineedits and button.

 

 

 

This is the design 

PyQt5 Login Design
PyQt5 Login Design

 

 

 

After completing the design you need to save the .ui file, iam going to name it login.ui, now copy the file and paste it in the Scripts folder of your Python installation, because we want to convert our ui file in to python file and for converting you need to use pyuic5 module. pyuic5 module is located in the Scripts folder of your Python installation, run this command for converting in your terminal.

 

 

 

So this is the converted file, also we have brought some changes to this file.

 

 

 

So we have added one method in our file and that is for login, first we want to get the email and password from the user and after we compare that with the registered email an password of our database. in the successful login we want to open the second dialog.

 

 

 

Also we have connected our QPushButton clicked signal with this method.

 

 

 

Run the complete code give the correct email and password.

PyQt5 Simple Login with Mysql Database
PyQt5 Simple Login with Mysql Database