Skip to main content

Password Generator (GUI)

Google gives you suggestions when you create your new passwords Right!

In the same way, python makes it too easy for you to create your own password generator rather than using other tools like google.

We are providing you the full source code with the explanation at every line which we are sure will help you.




# importing the tkinter module from tkinter import * # importing the pyperclip module to use it to copy our generated # password to clipboard import pyperclip # random module will be used in generating the random password import random # initializing the tkinter root = Tk() # setting the width and height of the gui root.geometry("400x400") # x is small case here # declaring a variable of string type and this variable will be # used to store the password generated passstr = StringVar() # declaring a variable of integer type which will be used to # store the length of the password entered by the user passlen = IntVar() # setting the length of the password to zero initially passlen.set(0) # function to generate the password def generate(): # storing the keys in a list which will be used to generate # the password pass1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', ' ', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')'] # declaring the empty string password = "" # loop to generate the random password of the length entered # by the user for x in range(passlen.get()): password = password + random.choice(pass1) # setting the password to the entry widget passstr.set(password) # function to copy the password to the clipboard def copytoclipboard(): random_password = passstr.get() pyperclip.copy(random_password) # Creating a text label widget Label(root, text="Password Generator Application", font="calibri 20 bold").pack() # Creating a text label widget Label(root, text="Enter password length").pack(pady=3) # Creating a entry widget to take password length entered by the # user Entry(root, textvariable=passlen).pack(pady=3) # button to call the generate function Button(root, text="Generate Password", command=generate).pack(pady=7) # entry widget to show the generated password Entry(root, textvariable=passstr).pack(pady=3) # button to call the copytoclipboard function Button(root, text="Copy to clipboard", command=copytoclipboard).pack() # mainloop() is an infinite loop used to run the application when # it's in ready state root.mainloop()




Comments

Popular posts from this blog

INSTALLING PYTHON (Anaconda)

 IN WINDOWS :  Download the Anaconda installer (TIP : IF IMAGES ARE BLURRED , TAP ON THEM FOR FULL SCREEN IMAGE) 1] Click the link the download will be started! 2]  Double click the downl oaded file to launch. 3] Click NEXT 4]  Read the licensing terms and click “I Agree”. 5] Select an install for “Just Me” 6] Select a destination folder to install Anaconda and click the Next button   7] Choose whether to add Anaconda to your PATH environment variable. We recommend not adding Anaconda to the PATH environment variable, since this can interfere with other software. Instead, use Anaconda software by opening Anaconda Navigator or the Anaconda Prompt from the Start Menu. 8] Choose whether to register Anaconda as your default Python. Unless you plan on installing and running multiple versions of Anaconda or multiple versions of Python, accept the default and leave this box checked 9] Click the Install button. If you want to watch the packages Anaconda is installing, c...

Jumble Words Game!

Jumbled word game :  Jumbled word is given to player, player has to rearrange the characters of the word to make a correct meaningful word. As we know this GUI code required Pyqt5 Module so before getting into code make sure to install pyqt5 in your system using the command, pip install pyqt5 You can use as many words you want to make the game more interesting or complicated. Code : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 18...

Flip Tiles. Memory Game!

CODE : Check Out Our Instagram Page : Instagram.com/Python.Coderss   # import modules from random import * from turtle import * # set the screen screen = Screen() #choose background color screen.bgcolor("yellow") # define the function # for creating a square section # for the game def Square(x, y): up() goto(x, y) down() color('white', 'green') begin_fill() for count in range(4): forward(50) left(90) end_fill() # define functionn to # keep a check of index number def Numbering(x, y): return int((x + 200) // 50 + ((y + 200) // 50) * 8) # define function def Coordinates(count): return (count % 8) * 50 - 200, (count // 8) * 50 - 200 # define function # to make it interactive # user click def click(x, y): spot = Numbering(x, y) mark = state['mark'] if mark is None or mark == spot or tiles[mark] != tiles[spot]: state['mark'] = spot else: hide[spot] = False hide[mark] = False state[...