-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpassword_generator.py
More file actions
57 lines (42 loc) · 1.43 KB
/
password_generator.py
File metadata and controls
57 lines (42 loc) · 1.43 KB
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
from tkinter import *
from random import randint
root=Tk()
root.title('Strong Password Generator')
root.iconbitmap()
root.geometry("500x300")
#generate strong password
def new_rand():
#clear our entry box
pw_entry.delete(0, END)
#Get PW Length and convert to integer
pw_length =int(my_entry.get())
#create a variable to hold our password
my_password= ''
#loop through password length
for x in range(pw_length):
my_password += chr(randint(33, 126))
#output passowrd to the screen
pw_entry.insert(0, my_password)
def clipper():
#clear to clipboard
root.clipboard_clear()
#copy to clipboard
root.clipboard_append(pw_entry.get())
#Label Frame
lf= LabelFrame( root, text="How many Characters?")
lf.pack(pady=20)
#create entry box to designate number of characters
my_entry = Entry (lf, font=("Helvetica", 24))
my_entry.pack(pady=20)
#create entry box for out returned password
pw_entry = Entry (root, text='', font=("Helvetica", 24), bd=0, bg= "systembuttonface" )
pw_entry.pack(pady=20)
#create a frame for buttons
my_frame= Frame(root)
my_frame.pack(pady=20)
#create our buttons
my_button= Button (my_frame, text="Generate Strong Password", command=new_rand)
my_button.grid(row=0, column=0, padx=10)
clip_button= Button(my_frame, text="Copy to Clipboard", command=clipper)
clip_button.grid(row=0, column=1, padx=10)
root.mainloop()