GUI Password Generator Using Python with Source Code

Introduction:

The term GUI refers to Graphical User Interface indicates that the application will be more interactive than static applications. The Password Generator is an application which is used in many real world applications like password recommendations in Gmail,Instagram etc,.

And we can  implement this using python.

How To Run The Code : 

Step 1 : Open the any Python Code Editor
Step 2 : Make a Python file passwordGenrator.py
Step 3 : Copy the code & Paste it 
Step 4 : Run the python file and you Program will run
Note : In this code you don’t have to install any Python Module and Does Not contain any Image so you can easily copy and paste the code.

 

Source Code : 

Get Discount on Top Educational Courses

Brand NameDiscount InformationCoupon Codes Link
Educative.io20% discount on Educative courses and plans
W3Schools20% discount on W3Schools courses
KodeKloud10% discount on KodeKloud courses and plans
GeeksforGeeks30% discount on GeeksforGeeks courses
Target Test Prep20% discount on Target Test Prep
Coding Ninjas₹5000 discount on Coding Ninjas courses
Skillshare40% discount on Skillshare
DataCamp50% discount on DataCamp
365 Data Science57% discount on 365 Data Science Plans
Get SmarterFlat 20% discount on Get Smarter courses
SmartKeedaFlat 40% discount on SmartKeeda courses
StackSocial20% discount on StackSocial courses
				
					# import all the required packages
# Visit : codewithcurious.com for more projects 
from tkinter import *
import random
import pyperclip

# To create a root window of GUI in python
tk=Tk()
tk.geometry('300x300')
tk.configure(background='yellow')

# To store/retrieve the string value entered by user
pswd=StringVar()

# To store/retrieve the Integer value entered by user
passlen=IntVar()
passlen.set('Enter Length')

# Function to generate a random password
def password_generator():
    characters='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 !@#$%^&*()'
    password=''
    if passlen.get()>=8:
        for i in range(passlen.get()):
            password+=random.choice(characters)
        pswd.set(password)

# Function to copy generated password to clipboard
def copyclipboard():
    random_password = pswd.get()
    pyperclip.copy(random_password)
    Label(tk,text="Copied to Clipboard",bg="red").pack(pady=6)
    
# Label to display the primary instruction to user to enter the length of passwod he requires
Label(tk, text="Enter the number to get password \n (Minimum length should be 8)",bg='Blue',fg='white').pack(pady=3)

# To store the entry of user
Entry(tk, textvariable=passlen).pack(pady=3)

# To generate Random password and confirmation by the button click
Button(tk, text="Generate Password", command=password_generator,bg='black',fg='white').pack(pady=7)
Entry(tk, textvariable=pswd).pack(pady=3)

Button(tk, text="Copy to clipboard", command=copyclipboard,bg='black',fg='white').pack()
# To initiate and display the root window we created
tk.mainloop()
				
			

Output :

Explanation :

1. First we imported all the required packages
random – To generate the random outcomes of an event in python we use random package
tkinter – To create the GUI based applications in python
pyperclip – To perform operations related to clipboard like coping etc.
 
2. Next we created a root window to display the content there with specified attributes.
 
3. Later we created two variables StringVar() and IntVar() to store / retrieve the string and integer values entered by the user.
 
4. Later on we created two functions to generate passwords and another function to copy the generated password to clipboard.
 
5. Finally we created Labels(Entry Points to data) and buttons used for functionality of the GUI.

Find More Projects

MathGenius Pro – AI-Powered Math Solver Using Python Introduction:From simple arithmetic to more complicated college-level subjects like integration, differentiation, algebra, matrices, and …

CipherMaze: The Ultimate Code Cracking Quest Game Using Python Introduction: You can make CipherMaze, a fun and brain-boosting puzzle game, with Python …

Warp Perspective Using Open CV Python Introduction: In this article, we are going to see how to Create a Warp Perspective System …

Custom AI Story Generator With Emotion Control Using Python Introduction: With the help of this AI-powered story generator, users can compose stories …

AI Powered PDF Summarizer Using Python Introduction: AI-Powered PDF Summarizer is a tool that extracts and summarizes research papers from ArXiv PDFs using Ollama (Gemma 3 LLM). The …

AI Based Career Path Recommender Using Python Introduction: One of the most significant and frequently perplexing decisions in a person’s life is …