-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPassword_generatorGUI.py
88 lines (59 loc) · 3.05 KB
/
Password_generatorGUI.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
from tkinter import *
import secrets
import string
def mot_de_passe(entrée_lettre, entrée_chiffre, entrée_ponctuation, longeur) :
if entrée_lettre == 0 :
lettre = ""
else :
lettre = string.ascii_letters
if entrée_chiffre == 0 :
chiffre = ""
else :
chiffre = string.digits
if entrée_ponctuation == 0 :
ponctuation = ""
else :
ponctuation = string.punctuation
alphabet = lettre + chiffre + ponctuation
password = ''.join(secrets.choice(alphabet) for i in range(longeur))
return password
print(mot_de_passe(1, 0, 0, 10))
def rep() :
nombre_de_caractres = entry2.get ()
nombre_de_caractres = int(nombre_de_caractres)
cochee1 = case_cochee1.get
cochee2 = case_cochee2.get
cochee3 = case_cochee3.get
password = mot_de_passe(cochee1(),cochee2(),cochee3(),nombre_de_caractres)
print(password)
entry.delete(0, END)
entry.insert(0, password)
fenetre = Tk()
fenetre.title("Password generator")
fenetre.geometry('900x600')
fenetre.minsize(700, 300)
fenetre.config(background= '#f2f2f2')
frame = Frame(fenetre, bg = '#f2f2f2')
#Titre
label_title = Label(frame, text= '1.Enter the number of characters you want.', font=("Arial", 20), bg = '#f2f2f2', fg ='#000000') #25 = taille police , bg = background texte , fg = front ground couleur texte. On peut soit afficher dans la fenêtre soit dans la frame
label_title.pack() #afficher ce qui y a dans label_title. Dans side on peut mettre side = YES pour avoir le texte tj au milieu
#entrée
entry2 = Entry(frame, text= "", font=("Arial", 25), bg = '#ececec', fg ='#000000') #25 = taille police , bg = background texte , fg = front ground couleur texte. On peut soit afficher dans la fenêtre soit dans la frame
entry2.pack(fill=X)
#case à cocher
case_cochee1 = IntVar()
case = Checkbutton(frame, text="letter",variable = case_cochee1 ,font=("Arial", 15), onvalue=1, offvalue=0)
case.pack()
case_cochee2 = IntVar()
case1 = Checkbutton(frame, text="digits",variable = case_cochee2 ,font=("Arial", 15), onvalue=1, offvalue=0)
case1.pack()
case_cochee3 = IntVar()
case2 = Checkbutton(frame, text="punctuation",variable = case_cochee3 ,font=("Arial", 15), onvalue=1, offvalue=0)
case2.pack()
button = Button(frame, text = "2.Generate password", font=("Arial", 20), bg = '#2e83ef', fg ='#000000', command = rep) #après command = mettre fonction
button.pack(fill=X)
#entrée
entry = Entry(frame, font=("Arial", 25), bg = '#a7a7a7', fg ='#000000') #25 = taille police , bg = background texte , fg = front ground couleur texte. On peut soit afficher dans la fenêtre soit dans la frame
entry.pack(fill=X)
frame.pack(expand = YES)
fenetre.mainloop()