Skip to content

Commit 5a79151

Browse files
committed
feat: Added password generator program
1 parent 2ca9cf2 commit 5a79151

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

Password Generator/main.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from tkinter import *
2+
from random import choice
3+
import string
4+
5+
class App:
6+
def __init__(self):
7+
self.window = Tk()
8+
self.window.title('password_generator')
9+
self.window.iconbitmap('logo.ico')
10+
self.window.iconphoto(False, PhotoImage(file='logo.png'))
11+
self.window.geometry('500x255')
12+
self.window.config(bg='gray')
13+
14+
self.label()
15+
self.entry()
16+
self.button()
17+
18+
def label(self):
19+
label_title = Label(self.window, text='Welcome to password generator', font=('Courrier', 20), bg='gray', fg='black')
20+
label_title.pack()
21+
22+
def entry(self):
23+
self.password_entry = Entry(self.window, font=('Courrier', 25), bg='white', fg='black', width=30, relief='solid')
24+
self.password_entry.pack(pady=50)
25+
26+
def button(self):
27+
password_generator = Button(self.window, text="Generate_password", font=('Courrier', 12), bg='white', fg='black', width=25, command=self.generate_password)
28+
password_generator.pack()
29+
30+
def generate_password(self):
31+
characters = string.ascii_letters + string.punctuation + string.digits
32+
password = ""
33+
for x in range(28):
34+
password+=choice(characters)
35+
self.password_entry.delete(0, END)
36+
self.password_entry.insert(0, password)
37+
38+
app = App()
39+
app.window.mainloop()

0 commit comments

Comments
 (0)