Course Content
PyQt5 Basics – Installation Process, Qt Designer Intro
In this part we are going to talk about some basics functionalities in PyQt5, we go through installation process, creating QPushButton, Signals and working with Qt Designer.
0/4
PyQt5 Tutorials
About Lesson

In this PyQt5 lesson we want to create Simple Login with Mysql Database, 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 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
Thank you for visiting my website! If you enjoyed the free courses, please consider supporting my works on Patreon.
Exercise Files
No Attachment Found
No Attachment Found