forked from fenyx-it-academy/Class4-PythonModule-Week4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweek4_1.py
More file actions
30 lines (25 loc) · 1.6 KB
/
week4_1.py
File metadata and controls
30 lines (25 loc) · 1.6 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
'''Emrah CINAR 01/31/21 21:40 '''
'''password generation program'''
import tkinter as tk
import random
def generate():
chars_tpl=('?>_<&!@*#%£§-æ')
numbers_tpl=('01234567899876543210')
bletters_tpl=('ABCDEFGHIJKLMNOPRSTUVYZ')
kletters_tpl=('abcdefghıjklmnoprstuvyz')
list_password=[]
list_fr=chars_tpl,numbers_tpl,bletters_tpl,kletters_tpl #tupllar degiskene atanir
while len(list_password)<10:
for i in list_fr: #tupl verileri i degiskenine atanir
list_password.append(i[random.randint(0,(len(i)-1))]) # i degisken uzunlugu tespit edilip,0 dan uzunluga kadar randint ile rastgele
if len(list_password)==10: #rakam secilir.i[] ile bu rakam index olarak kullanilip, indexin karsiligi olan rakam append ile listeye eklenir,
label['text']=("".join(list_password)) #eklenen karakter uzunlugu 10 oldugunda bu satir ile labele gonderilir
#orada bulunan text ile degistirilir ve pencerede gosterilir,
root = tk.Tk()
root. title('Generate Password by emrah') #pencere adi
root.geometry("350x250+575+50") #pencere boyutlari ve ekrandaki konumu
label=tk.Label(text='sifreniz',fg="white",bg="black",padx=20,pady=20) #sifrenin gosterildigi etiket
label.pack() #labelin gosterilmesini saglayan satir
button_password=tk.Button(root, text='Generate',fg="blue",padx=20,pady=20,command=generate) #dongunun calismasini saglayan button (command=generate)
button_password.pack()
root.mainloop() #pencerenin devamli olarak gorunmesini saglar