• Home
  • Tutorials
    • Python
    • Machine Learning
    • Pygame
    • Python Quiz
  • 100+ Projects
    • 100+ Python Projects
    • 100+ Java Projects
  • PYTHON HANDWRITTEN NOTES
    • Python Short Notes
    • Complete DSA Notes
    • Python Detailed Notes
  • Python Compiler
    • All Editors
    • Turtle Compiler
    • Online Java Compiler
    • Online C++ Compiler
    • Online C Compiler
  • Contact Us
    • About Us
    • Policy
  • Our Android Apps
    • Unlimited Python Exercises App
    • Complete Linux Commands App

CopyAssignment

We are Python language experts, a community to solve Python problems, we are a 1.2 Million community on Instagram, now here to help with our blogs.

×

Login System in Tkinter Python

 Ayush Purawr  January 27, 2021
Login System in Tkinter Python

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:

Login System

Hope you liked this project.
Comment down your views/queries if you have.


Also Read:


  • SQLite CRUD Operations in Python
    SQLite | CRUD Operations in Python
    CRUD 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 Python
    Event Management System Project in Python
    In 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 Python
    Ticket Booking and Management in Python
    Hello 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 Python
    Hostel Management System Project in Python
    In 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…
  • Sales Management System Project in Python
    Sales Management System Project in Python
    Hello friends, in this article, we will see Sales Management System Project in Python. We will add basic features like adding products, deleting products, updating products, and viewing all products. We have used inbuilt SQLite3 for database purposes and tkinter for GUI. Project overview: Sales Management System Project in Python Project Name: Sales Management System…

Share:
Avatar of Ayush Purawr

Author: Ayush Purawr

Post navigation

← Complete Game In PyGame and Python
Desktop Battery Notifier using Python →

Categories

30 Days of Code allcategorites assignment c and cpp competitive programming data structures and algorithms django tutorial final year project game in python general-python gfg github-copy gui java project gui python projects how-to html css javascript project java java game projects java projects job leetcode Machine Learning ml-shorts ml ai ds project php projects programs in python project ideas pygame tutorial python-error python-short-tutorial python projects python simple programs python sqlite qna python turtle python very small program assignments tutorial web projects

Search….

SiteMap

Python

Machine Learning

Pygame

Data Structures and Algorithms(Python)

Python Turtle

Games with Python

All Blogs On-Site

Python Compiler(Interpreter)

Online Java Editor

Online C++ Editor

Online C Editor

All Editors

Services(Freelancing)

Recent Posts

  • Top 25 Pattern Programs in C++
  • Currency Converter in C++
  • SQLite | CRUD Operations in Python
  • Number Guessing Game in C++
  • Image background remover in Python

Must Read

  • 100+ Python Projects
  • 100+ Java Projects
  • Python Programs
  • JavaScript Projects
  • Java Projects
  • PHP Projects

RoadMap to Learn

  • Python
  • Java
  • JavaScript

Python Handwritten Notes

Click Here to buy now

Python Assignment Help

We also deal with Python Assignments, Homeworks, and Projects. Click Here, to get your Python work done by experts.

close button

© Copyright 2022 www.copyassignment.com. All rights reserved. Developed by copyassignment