Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_strong_password_generator.py
- from tkinter import *
- import random
- import string
- words = string.ascii_uppercase
- words2 = string.ascii_lowercase
- numbers = string.digits
- spec_char = '!@#$%'
- class GenPass:
- def __init__(self, master):
- frame = Frame(master) # add parent for Frame
- frame.pack()
- self.printButton = Button(frame, text="Generate Password", padx=4, pady=4, command=self.generate)
- self.printButton.pack(side=LEFT)
- self.quitButton = Button(frame, text="Copy to Clipboard", padx=4, pady=4, command=master.destroy) # zzz
- self.quitButton.pack(side=LEFT)
- self.output = Label(master, fg="Green")
- self.output.pack()
- self.generate() # genrate password at start
- def generate(self):
- password = []
- for i in range(2):
- password += [random.choice(words)]
- for i in range(2):
- password += [random.choice(words2)]
- for i in range(2):
- password += [random.choice(numbers)]
- for i in range(2):
- password += [random.choice(spec_char)]
- for i in range(8):
- password += [random.choice(words+words2+numbers+spec_char)]
- random.shuffle(password)
- password = ''.join(password)
- print(password)
- self.output.config(text=password)
- root = Tk()
- GenPass(root)
- root.mainloop()
Add Comment
Please, Sign In to add comment