-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPassword Generator.py
More file actions
50 lines (34 loc) · 1.18 KB
/
Copy pathPassword Generator.py
File metadata and controls
50 lines (34 loc) · 1.18 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
from tkinter import *
import pyperclip
from random import choice
from string import printable
root = Tk()
photo = PhotoImage(file='Junior.png')
root.iconphoto(False, photo)
root.title('PW Gen - Joe')
root.geometry("500x250")
passstr = StringVar()
passlen = IntVar()
passlen.set(0)
def generate_password() -> str:
random_characters = list(printable)[:-5]
password = ""
for _ in range(passlen.get()):
password += choice(random_characters)
passstr.set(password)
def copytoclipboard():
random_password = passstr.get()
pyperclip.copy(random_password)
Label(root, text="Password Generator", font="calibri 25 bold").pack()
Label(root, text="Enter password length").pack(pady=3)
Entry(root, textvariable=passlen).pack(pady=3)
Button(root, text="Generate Password", command=generate_password).pack(pady=7)
Label(root, text="Password Generated").pack(pady=3)
Entry(root, textvariable=passstr).pack(pady=3)
Button(root, text="Copy to clipboard", command=copytoclipboard).pack()
root.mainloop()
"""
Feel free to commment/critique anything here
Would also love to gain some understanding as to why PhotoImage() does not work for me
Thanks
"""