Python Login Registration Form

Python Login Registration Form – In this article i will explain how develop python Login Registration Form example with validation (tkinter) in Pycharm IDE. Pycharm is a best python website and android application development platform and also we cam simulate IoT based projects in pycharm editor. Here click to download pycharm IDE software Download. IF you are beginner in python don’t worry you can easily understand this concept. You must know the OOPs basic things for learn every programming languages like java angular.

Now a days most of college students choose python programming language for their final year projects because most of software companies hire python developers so students are like to learn python language.

Python is a server side scripting language used for develop web applications, mobile applications, Internet Based application (IoT) on python. Python is demand language so you can choose python for your college major project.

Create New Python Project

There are more IDE (Integrated Development Environment) available in the market for develop python mobile and web application development. Most of developers prefer Pycharm IDE for developement. In this article we also use pycharm ide because more features added in this platform.

First create New Python file and give some name for that, after creating project import Tkinter module. Tkinter is the GUI (Graphical User Interface) library file. Its used for develop GUI based application. When you have import tkinter library for your project then you can make fast and perfect design layout of GUI application. wxPython and Jpython GUI library available but Tkinter is best GUI library module.

Import Tkinter Library

Tkinter provides powerful object oriented interface for GUI toolkit. Use below single line code for import the tkinter.

from tkinter import *

Example

Here i will give the simple example for importing tkinter module in our python GUI application development. Follow these procedure before starting the project,

import Tkinter
top = Tkinter.Tk()
# Code to add widgets will go here...
top.mainloop()

In the above code make simple GUI widow. Output looks like,

tkinter output screen

Hereafter we develop simple login and registration form in python using import the tkinter library.

Also Read – Python Projects

Create Login Register Form Python

In this project first we have to develop login page Username and Password create new file and give name for login.py then add following below code,

from tkinter import *

window = Tk()
window.title("ItsExceptional")
window.geometry("300x200")
window.config(background = "black", pady=10)

lb1 = Label(window, text = "Login Form", bg = "black", fg="white", font=20)
lb1.place(x=110, y=5)

lb2_u = Label(window, text = "Username - ", bg="black", fg="white")
lb2_u2 = Entry(window)
lb2_u.place(x=10, y=40)
lb2_u2.place(x=110, y=40)

lb2_p = Label(window, text = "Password - ", bg="black", fg="white")
lb2_p2 = Entry(window)
lb2_p.place(x=10, y=80)
lb2_p2.place(x=110,y=80)
display = Label(window, text="Access : ", bg="black")
bt = Button(window, text="Login")

def dis():
    user = lb2_u2.get()
    pas = lb2_p2.get()
    filo = open('register.txt').readlines()
    for lino in filo:
        if user == lino.split()[2]:
            display.config(bg="green",fg="white", text="Access :Granted")
            break
        else:
            display.config(bg="red",fg="white", text="Access :Denied")
bt.config(command=dis)
bt.place(x=110, y=120)

def newsign():
    sign=Tk()
    sign.title("SignUp")
    sign.geometry("300x200")
    sign.config(background = "black", pady=10)

    lbs = Label(sign, text = "SignUp", bg = "black", fg="white", font=20)
    lbs.place(x=110, y=5)
    lb2_s = Label(sign, text = "Username - ", bg="black", fg="white")
    lb2_s2 = Entry(sign)
    lb2_s.place(x=10, y=40)
    lb2_s2.place(x=110, y=40)
    lb2_ps = Label(sign, text = "Password - ", bg="black", fg="white")
    lb2_ps2 = Entry(sign)
    lb2_ps.place(x=10, y=80)
    lb2_ps2.place(x=110,y=80)

    dis = Label(sign, text ="", bg="black", fg="white")
    
    def reg():
        username = lb2_s2.get()
        pas = lb2_ps2.get()

        file =  open("register.txt","a")
        fiIn = open('register.txt').readlines()
        l=[] 
        for lines in fiIn:
            l.append(lines.split()[2])
        if username in l:
            print("Exists")
            dis.config(text="User Exists", bg="green")

        else:
            print("not Exists")
            file.write("Username = "+username+"\n")
            file.write("Password = "+pas+"\n")
            file.close()
            dis.config(text = "Registered", bg="green")
    
    bts = Button(sign, text="Register", command=reg)
    bts.place(x=110, y=120)
    dis.place(x=100, y=150)
    window.destroy()
bt2 = Button(window, text="SignUp", command=newsign)
bt2.place(x=170, y=120)
display.place(x=110, y=155)

If you face any error, just comment below i will try to solve your queries and doubts as soon as possible. Actually Login and Signup form is very important for every project so you should increase your knowledge for further development issues.

Leave a Reply