-
Notifications
You must be signed in to change notification settings - Fork 0
/
TASK_3-Strong Password Generator
53 lines (38 loc) · 1.33 KB
/
TASK_3-Strong Password Generator
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
from tkinter import *
from random import randint
root =Tk()
root.title("Strong Password Generator")
root.iconbitmap("C:\gui\pass_gene.ico")
root.geometry("500x500")
#Generate random Strong password
def new_rand():
#clear our entry box
pw_entry.delete(0,END)
#get password length and covert to integer
pw_length = int(my_entry.get())
#create variable to hold password
my_password = ''
# loop through password lenght
for x in range(pw_length):
my_password += chr(randint(33,126))
#print passwod on screen
pw_entry.insert(0, my_password)
# copy to our clipboard
def clipper():
root.clipboard_clear() #clear clipboard
root.clipboard_append(pw_entry.get()) #copy to clipboard
#Label frame
lf = LabelFrame(root, text="How many characters?")
lf.pack(pady=20)
my_entry = Entry(lf, font=("Helvetica",24),borderwidth=5)
my_entry.pack(pady=20, padx=20)
pw_entry = Entry(root , text='', font=("helvetica",24),borderwidth=5, bd=0,bg="systembuttonface")
pw_entry.pack(pady=20)
#create frame for buttons
my_frame = Frame(root)
my_frame.pack(pady=20)
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()