DEV Community

loading...
Cover image for Password Creator GUI using PyCharm

Password Creator GUI using PyCharm

rutikab12 profile image Rutik Bhoyar ・2 min read

It is a tool that generates passwords based on the given guidelines that you set to create an unpredictable strong password for your accounts.

The Password generator tool creates a random and customized password for users that helps them to create a strong password which provides greater security.

Prerequisites
To build this project we will use the basic concept of python and libraries – Tkinter, pyperclip, random, string.

1.Tkinter is a standard GUI library and is one of the easiest ways
to build a GUI application.
2.pyperclip module allows us to copy and paste text to and from
the clipboard to your computer
3.The random module can generate random numbers
4.string module contains a number of functions to process the
standard python string.

pip install tkinter
pip install pyperclip
pip install random
pip install strings
Enter fullscreen mode Exit fullscreen mode

Steps

  1. Import Libraries
    The first step is to import libraries

  2. Initialize Window
    Tk() initialized tkinter which means window created
    geometry() set the width and height of the window
    resizable(0,0) set the fixed size of the window
    title() set the title of the window
    Label() widget use to display one or more than one line of
    text that users can’t able to modify.
    root is the name which we refer to our window
    text which we display on the label
    font in which the text is written
    pack organized widget in block

  3. Select Password Length

  4. Function to Generate Password

  5. Function to Copy Password

from tkinter import *
import random, string
import pyperclip
rutik_root = Tk()
#width x height
rutik_root.geometry("400x400")
#width, height
rutik_root.minsize(200,100)
rutik_root.maxsize(1200,800)
rutik_root.title("Rutik - Password Generator")

Label(rutik_root,text="Password Generator", font="arial 15 bold").pack()
Label(rutik_root,text="Rutik", font="arial 15 bold").pack(side=BOTTOM)

pass_label=Label(rutik_root,text="Password Length", font="arial 15 bold").pack()
pass_len=IntVar()
length=Spinbox(rutik_root,from_ =8, to_ = 32, textvariable = pass_len, width = 15).pack()

pass_str = StringVar()
def Generator():
    password = ''

    for x in range(0,4):
        Password = random.choice(string.ascii_uppercase)+random.choice(string.ascii_lowercase)+random.choice(string.digits)+random.choice(string.punctuation)
    for y in range (pass_len.get()- 4):
        password = password+random.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits + string.punctuation)
    pass_str.set(password)

Button(rutik_root,text =" Generate Password", command = Generator).pack(pady=5)
Entry(rutik_root, textvariable = pass_str).pack()

def Copy_password():
    pyperclip.copy(pass_str.get())
Button(rutik_root,text =" Copy to Clipboard", command = Copy_password).pack(pady=5)
rutik_root.mainloop()
Enter fullscreen mode Exit fullscreen mode

And finally you will be getting an GUI Window like below.

Alt Text

Discussion (0)

pic
Editor guide