In this tutorial, we are going to make a Login System in Tkinter Python. For this project, you need to have the Tkinter module.
This small project will contain features of login and signup systems as we saw in your daily life. Using this project, you will come to know a little information about how the login systems of all websites/applications work.
You can install Tkinter Module by writing the below command in your python terminal.
pip install tkinter
We also need to create a .txt file for saving the data of the users and validating the data entered by the user. Here I have made a file named Login.txt. You can give your name as per your choice.
Login System in Tkinter Python: Complete Code
from tkinter import * import tkinter.messagebox as tsmg root=Tk() def check(): a=uname.get() b=pwd.get() c=cpwd.get() mix=a+"-"+b+"-"+c // Instead of Login.txt you should write your file name. with open("Login.txt","r") as fi: d=fi.readlines() if b==c: if str(mix) in str(d): tsmg.showinfo("Welcome",f"Hello {a}, You Have SuccessFully Logged In") else: tsmg.showerror("Error","No User Found, Please Sign-Up First") else: tsmg.showerror("Error","Both Password Are Different") uname.set("") pwd.set("") cpwd.set("") def save(): a=uname.get() b=pwd.get() c=cpwd.get() mix=a+"-"+b+"-"+c if a!="" and b!="" and c!="" : with open("Login.txt","r") as fi: d=fi.readlines() if str(mix) in str(d): tsmg.showerror("Error","You Already Have An Account, Please Login") uname.set("") pwd.set("") cpwd.set("") elif str(a) in str(d): tsmg.showerror("Error","Username Already Exist") uname.set("") pwd.set("") cpwd.set("") else: if b==c: with open("Login.txt","a") as f: f.write(f"{a}-{b}-{c}\n") tsmg.showinfo("Success","Your Account Has Been Created") uname.set("") pwd.set("") cpwd.set("") else: tsmg.showerror("Error","Both Password Are Different") uname.set("") pwd.set("") cpwd.set("") uname=StringVar() pwd=StringVar() cpwd=StringVar() root.geometry("700x500") root.title("Welcome To My Page") f=Frame(root) Label(f,text="Login To Continue",font="SegoeUI 18 bold",pady=10).pack() f.pack() f=Frame(root) Label(f,text="Username",font="SegoeUI 14 bold",pady=5).pack() e1=Entry(f,textvariable=uname,font="SegoeUI 14 bold",borderwidth=5,relief=SUNKEN).pack(padx=5,pady=5) Label(f,text="Password",font="SegoeUI 14 bold",pady=5).pack() e2=Entry(f,textvariable=pwd,font="SegoeUI 14 bold",borderwidth=5,relief=SUNKEN).pack(padx=5,pady=5) l1=Label(f,text="Conform-Password",font="SegoeUI 14 bold",pady=5).pack() e3=Entry(f,textvariable=cpwd,font="SegoeUI 14 bold",borderwidth=5,relief=SUNKEN).pack(padx=5,pady=5) f.pack() f=Frame(root) b1=Button(f,text="Login",font="SegoeUI 10 bold",command=check).pack(side=LEFT,pady=10,padx=10) b2=Button(f,text="Sign-Up",font="SegoeUI 10 bold",command=save).pack(side=LEFT,pady=10,padx=10) f.pack() f=Frame(root) Label(f,text="Don't Have An Account Then Sign-Up",font="SegoeUI 14 bold",pady=5).pack() f.pack() root.mainloop()
Output:
Hope you liked this project.
Comment down your views/queries if you have.
- Create your own ChatGPT with PythonChatGPT is a product of openai, currently ChatGPT is the most famous product of openai but there are many other products. In this article, we will see how to use ChatGPT with Python means we create a program that can be used to simulate ChatGPT just like it does on https://chat.openai.com/chat/. So, we are really going…
- SQLite | CRUD Operations in PythonCRUD stands for Create Read Update Delete. I will show you how to perform CRUD Operations in Python. You need basic Tkinter and SQLite knowledge before you read further. This app is straightforward, when you will open this app, a GUI with 4 green colored buttons will open to perform CRUD(create read update delete) operations….
- Event Management System Project in PythonIn this article, we will create Event Management System Project in Python with source code. Using this event management system, one can easily maintain ticket bookings for different events. This is a GUI project and we have created different files and modules to organize the different functions used in this system. Features of Event Management…
- Ticket Booking and Management in PythonHello friends, in this article we will build Ticket Booking and Management in Python. This app will simulate a general Ticket management system means this can be used for general ticket management just like a token. There will be 4 fields that will be used for managing tickets, 4 fields will be name(of person), ticket…
- Hostel Management System Project in PythonIn this article, we will build a Hostel Management System Project in Python with Graphical User Interface and database integration. We will use the MongoDB database with pymongo module for managing data. This application can help hostel owners to make their work more convenient and Increase their Service Quality. This application can help users with…