-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
129 lines (93 loc) · 3.31 KB
/
main.py
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
from tkinter import*
import Create
root = Tk()
# Variables
t = False
s = False
n = False
low = False
upp = False
password = "Insert Length of characters above ^"
##Methods############################
#####################################
def gen_password():
try:
# Get Entry
size = Size_Entry.get()
# Set Entry to int
s = int(size)
if(s > 7 and s < 25):
try:
# Set Gen Button to Disabled
dis()
# Update Gen Button
Generate_Button.update()
print("Gen Started...")
# Delete Entry Bar
Password_Entry.delete(0, "end")
password = Create.create(s, t, s, n, low, upp)
# Insert new password string
Password_Entry.insert(END, password)
# Copy to clipboard
try:
root.clipboard_clear()
root.clipboard_append(password)
Show_Copied.place(x=56, y=56)
except:
print("Failed to copy to clipboard")
except:
Password_Entry.delete(0, "end")
Password_Entry.insert(END, "Failed to generate")
dis()
finally:
dis()
print("Gen_Password Finished")
else:
print("Size not correct")
Password_Entry.delete(0, "end")
Password_Entry.insert(END, "Size MUST be 8-24 characters")
except:
print("Size not correct")
Password_Entry.delete(0, "end")
Password_Entry.insert(END, "Size MUST be a Integer")
finally:
print("End")
def dis():
if Generate_Button["state"] == NORMAL:
Generate_Button["state"] = DISABLED
Generate_Button["text"] = "Generating"
Generate_Button["bg"] = "Pink"
else:
Generate_Button["state"] = NORMAL
Generate_Button["text"] = "Generate"
Generate_Button["bg"] = "LightGreen"
##SET#########################################
##############################################
##Title#######################################
root.title("CL's Password Generator")
##Window######################################
root.geometry('338x80+700+200')
##Label Widget################################
My_Label = Label(root, text="Password: ")
Size_Label = Label(root, text="Size: ")
Size_Instructions = Label(root, text="<== Character length: 8-24")
Show_Copied = Label(root, text="Copied to Clipboard",fg="Green")
##Button#####################################
Generate_Button = Button(root, text="Generate", bg="LightGreen", width=10,height=4,bd=4, command=(lambda: gen_password()))
##Entry Widget###############################
Password_Entry = Entry(root, bd=4, width=30)
Size_Entry = Entry(root, bd=5, width=2)
###Draw to Screen############################
#############################################
##Buttons####################################
Generate_Button.place(x=250,y=2)
##Labels####################################
My_Label.place(x=0,y=32)
Size_Label.place(x=0,y=2)
Size_Instructions.place(x=70,y=2)
Show_Copied.place_forget()
##Entries##################################
Password_Entry.place(x=60,y=30)
Size_Entry.place(x=40,y=2)
##MainLoop################################
root.mainloop()