Skip to main content

Create a login page using python| Login page using python| Pythonticate | python for beginner

 Hello python coders,

In this post you are going to see that how you can create a simple login page using python. To perform this activity you must have installed python on your machine.



Let's talk about coding, first of all you have to import some modules like - from tkinter import * , from venv import create, from email.mime import image, from cgitb import text.  then you should proceed for creating a window. 

To create a window you have to declare root = Tk()  and then to appear as a window you have to form a loop using root.mainloop().  After doing this you will see a window named tk will appear on your screen.

Now you have to change your window name that is from tk to the which you like, for that you have to use root.title("Your fav name")  this function will help you to write name of your window like if you want to name your window Python coder the you have to write root.title("Python coder")  it will change your windows name from tk to Python code. 

After changing the name you should try to change the icon of your window. Now, for doing this you have to type root.iconbitmap("login1.ico")  in which login1.ico is an image file (.png .jpg .jpeg) which is further converted into icon file type , for the conversion of normal image to icon i have used a website which will helped me to convert my image to icon format and save that icon file with .ico extension. 

After the successful insertion of icon you can insert any image or you can directly start form creation for login page.

for inserting the image you have to use the picture = PhotoImage(file="admin01.png")

lab = Label(root, image=picture) module to insert any image in your form, 

where you can insert any image in format of .jpg, .png, .jpeg or any other supported format.

And now if want to and any thing else you can try for it.

Now you are ready to create the login form. We have to find out that what are the data are filled in login form,

like - email, Contact number, Unique ID, . and what are the data filled in password.

Generally username contains - email, mobile number or ID and password depends on user's choice.

For the creation of username we have to write - username = Label(root, text="Username", font="none 15", bg="#424949", fg="white")

and for the password - password = Label(root, text="Password", font="none 15", bg="#424949", fg="white"), these two lines of code help to ask user to enter the username and password.

And you have to close or pack these two functions otherwise you are not going to get a proper output, For closing these functions you have to write -username.grid(row=1, column=0, pady=10)

this finction will close the username and password.grid(row=2, column=0, pady=10) this function will close the password funtion. One more thing i would like to tell you that, 

you can clearly see in the coding part its clearly mentioned...what are the font size , what are the font color , which color is backgrounf color and which color is foreground color.

Now you have to create an area where user can enter thair details, for doing this you need to create two boxes in which user can enter their details.

For creating the boxes you have to write - username_box = Entry(root, font="none 15", w=20) this function will help you to create the box for username and 

password_box = Entry(root, font="none 15", w=20, show="*") this function will help you to create box for password, in this you can find show="*" this function helps you to hide your password.

Now as we have done previously, we have to close or pack this function. For closing the function we have to write -

username_box.grid(row=1, column=1, pady=10)this function will help you to close the username box and

password_box.grid(row=2, column=1, pady=10)this function will help you to close the password box.

As we have completed with form creation and getting details form user to fill in the form like username and password, 

Now we have to create a login button, which help you to login to your accout if you have entered your details correctly.

for the login button creation - login = Button(root, text="Login", padx=30, pady=10) and as we have done previosly we have to close it or we have to pack it so, for closing this function we have to write -

login.grid(row=3, columnspan=2, column=0, pady=10) this function will close the login button function and helps to create the login button.

If you have done every thing in a proper way then you are going to get the output as you run your program or it shows error try to slove it.

I hope you people have understand how to create a login page using python.





Code - 

from cgitb import text

from email.mime import image

from logging import root

from tkinter import *

from venv import create

root = Tk()

root.geometry("500x500")

root.configure(bg="#424949")

root.title("Login page")

root.iconbitmap("login1.ico")

picture = PhotoImage(file="admin01.png")

lab = Label(root, image=picture)


username = Label(root, text="Username", font="none 15", bg="#424949", fg="white")

password = Label(root, text="Password", font="none 15", bg="#424949", fg="white")


username_box = Entry(root, font="none 15", w=20)

password_box = Entry(root, font="none 15", w=20, show="*")


login = Button(root, text="Login", padx=30, pady=10)


lab.grid(row=0, column=0, columnspan=2, padx=95, pady=40)


username.grid(row=1, column=0, pady=10)

password.grid(row=2, column=0, pady=10)


username_box.grid(row=1, column=1, pady=10)

password_box.grid(row=2, column=1, pady=10)


login.grid(row=3, columnspan=2, column=0, pady=10)


root.mainloop()



Comments

Post a Comment

Thank you for sharing this.

You’re helping us become better. Want to stay in the loop? Subscribe to our YouTube channel.

Popular posts from this blog

Android 13 features| Android 13 updates| Material You design| language Customizable| Android themes Privacy and security controls in Android 13| App Hibernation in Android 13| Adaptive Charging in Android 13| Android 13 release date| Android Beta Program| Latest Android version

 Android 13: What's New and Exciting? Android 13, codenamed Tiramisu, is the latest version of Google's mobile operating system that is expected to launch in late 2023. Android 13 promises to bring a host of new features and improvements to enhance the user experience, security, and performance of Android devices. In this blog post, we will take a look at some of the most anticipated features of Android 13 and how they will benefit users and developers alike. One of the biggest changes in Android 13 is the introduction of Material You, a new design language that adapts to the user's preferences, mood, and context. Material You allows users to customize their device's theme, colors, fonts, icons, and shapes according to their personal style and taste. Material You also changes dynamically based on the time of day, the wallpaper, the app, and the device mode. For example, if the user switches to dark mode, the system will automatically adjust the colors and brightness to ...

DALL-E AI, AI-generated images, GPT-3, OpenAI, artificial intelligence, natural language processing, deep learning, neural networks, image synthesis, image recognition, visual content creation.

 DALL.E is an AI system that can create images from text descriptions, using a large neural network trained on a dataset of text-image pairs. It was introduced by OpenAI in January 2021, and has since been improved with DALL.E 2, which generates more realistic and accurate images with higher resolution. In this blog post, I will explain how DALL.E works and show some examples of its amazing capabilities. DALL.E is based on GPT-3, a transformer language model that can generate text for a wide range of tasks. DALL.E extends GPT-3 by adding image tokens to its vocabulary, allowing it to generate both text and images in a single stream of data. DALL.E receives both the text and the image as input, and is trained to generate all of the tokens, one after another, using maximum likelihood. To represent images, DALL.E uses a discrete variational autoencoder (VAE) that compresses each image to a 32x32 grid of discrete latent codes. Each code corresponds to one of 8192 possible image tokens....

Nurturing Wellness: Embracing a Healthy Lifestyle in Today's Fast and Busy World| Healthy lifestyle tips| Wellness in a fast-paced world| Balancing health and busy schedule| Prioritizing well-being| Healthy living strategies

Introduction: In today's fast-paced and hectic world, it is increasingly challenging to prioritize our health and well-being. As our lives become busier, our schedules more demanding, and technology constantly vying for our attention, the pursuit of a healthy lifestyle often takes a backseat. However, it is crucial to recognize that living a healthy life is not only essential for our physical well-being but also plays a significant role in our mental and emotional resilience. This comprehensive blog post aims to delve into the complexities of maintaining a healthy lifestyle amidst the demands of modern life. Through a thorough exploration of various aspects of well-being, practical tips, and evidence-based guidance, we hope to equip you with the knowledge and tools necessary to embrace a healthy lifestyle that nurtures your mind, body, and spirit. Section 1: The Foundations of a Healthy Lifestyle: 1.1 Understanding Health and Wellness: Defining health and wellness in the modern con...