Python GUI Login – Graphical Registration And Login System In Python

Welcome to Python GUI Login tutorial. In this tutorial i will teach you to create a Login form where user can register themselves and can login. Registration and Login requires everywhere,  either you are filling any form or want to access any application. So in this tutorial we will see how to implement user registration and login in python.

In this, we will create a GUI interface. Python provides Tkinter toolkit to develop GUI applications. In python, you can develop any GUI applications easily. If you have ideas then you can turn your imagination into reality and make many creative things in programming. So without wasting time let’s start our Python GUI Login tutorial. It may be lengthy so guys please keep patience and follow this till the end, and i am pretty sure you will learn much knowledge and also enjoy.

Python GUI Login
Python GUI Login

Python GUI Login Tutorial – Getting Started With Tkinter

Creating New Project

Open your IDE and create a new project and then inside this project create a python file. I prefer PyCharm but you can prefer anyone as it doesn’t matters, but if you want to know best python IDEs then refer Best Python IDEs.

 Importing Tkinter Module

For importing tkinter just write one line of code.

Designing Main Screen

So first of all you have to design the main screen. This screen have two buttons Login and Register. So let’s see how to implement this.

  • You can also customize the design of main screen as per your choice and make it more attractive.
  • So let’s see the output of this code.
Python GUI Login
Python GUI Login

Designing New Screen For Registration

Now we will design a new screen for registration. That means if a user press register button on main screen then a new window will appear where users have to enter username and password. And this way they can register themselves. So let’s see how to do that.

And now we have to add two things inside the main_account_screen() method.

So now we can see the registration window

Python GUI Login
Python GUI Login

So, as user clicks register button on main window(first) then a new screen will be appear where user have to enter their entry.

Assigning Functions To Register Button

Now we have to implement event on register button. It means, after filling the entries, as soon as the register button is pressed, entries are saved in a file. So let’s see how to do it.

And now we have to declare username, password, username_entry, password_entry as global so add following codes inside register() function

And add one more thing inside register() function

And now we will finally test our registration process. So fill the username and password field in register form and press register button. You will find, a Registration Success message on screen. So let’s see the output.

Python GUI Login
Python GUI Login

And after registration a text file has been created which contain user’s informations such as username and password. So the file like –

Python GUI Login
Python GUI Login

So you can see username and password have been saved successfully in this file.

Finally we have completed register process and now its time to move towards login process. So let’s start.

Designing New Screen For Login

We have seen register process, now we have to implement login process. So for this, first of all  we have to design a login window. It is same as register window but having little changes. So the code for login is –

The above code is same as we have done in register so here i am not explaining it.

And now add a line inside main_account_screen()

And now define login verification function.

And now our login screen look like –

Python GUI Login
Python GUI Login

Login Verification Process

In this section we will verify the username and password for login. So let’s start

Defining Verification function

Designing Login Success Popup

Now we will define a function that will show a popup for successful login. If user has entered the valid entries then this popup will appear. So let’s see how to do it.

And now define a function for deleting the popup. So write the code.

So now let’s see the output. If the user enter the valid username and password then the popup will appear as below.

Python GUI Login
Python GUI Login

Designing Invalid Password Popup

If user enter wrong password then a popup for  invalid password will appear. So to do this we will define the following method.

And now define a function for deleting this popup. So write the code.

So see the result,

Python GUI Login
Python GUI Login

You can destroy this by pressing OK button.

Designing User Not Found Popup

If user enter wrong username then a popup for  User Not Found will appear. So to do this we will define the following method.

And now define a function for deleting this popup. So write the code.

So now we will see the output of above code.

Python GUI Login
Python GUI Login

Complete Code For Python GUI Login

You can customize the look of windows as per your choice.

Recommended Articles :

So this was Python GUI Login tutorial. I hope you have understand this very well. If you found it helpful then please share with others. And if you are getting any difficulty while doing this then comment your queries. Thanks

11 thoughts on “Python GUI Login – Graphical Registration And Login System In Python”

  1. Are the passwords and usernames stored server sided? So if other people download this on other computers they will still need a unique username and password?

    Reply
  2. May I know how to I integrate this into another GUI. I want to make it so when I successfully login I can go into this other GUI and for both to work perfectly fine like it’s a standalone.

    Reply
  3. Thanks a lot, but the registration info not saved in a table inside a Database, can we make this ? i really appreciated your effort

    Reply

Leave a Comment