from tkinter import *
import random
def tst():
txt1.delete('1.0', END)
txt1.insert(1.0, maincycle())
txt2.delete('1.0', END)
txt2.insert(1.0, maincycle())
txt3.delete('1.0', END)
txt3.insert(1.0, maincycle())
txt4.delete('1.0', END)
txt4.insert(1.0, maincycle())
txt5.delete('1.0', END)
txt5.insert(1.0, maincycle())
txt6.delete('1.0', END)
txt6.insert(1.0, maincycle())
txt7.delete('1.0', END)
txt7.insert(1.0, maincycle())
txt8.delete('1.0', END)
txt8.insert(1.0, maincycle())
def maincycle():
wrd1='abcdefghijklmnopqrstuvwxyz'
wrd2=wrd1.upper()
wrd3='1234567890'
wrd4='!@#$%^&*()_.,<>?'
prps=''
if var1.get()==0:
prps+=wrd1
if var2.get()==0:
prps+=wrd2
if var3.get()==0:
prps+=wrd3
if var4.get()==0:
prps+=wrd4
ln=list(prps)
pswd = ''
if spin.get().isdigit()==True:
if (var1.get()==1 and var2.get()==1 and var3.get()==1 and var4.get()==1) or int(spin.get())<=0 or int(spin.get())>=31:
return(' - ')
else:
random.shuffle(ln)
pswd = ''.join(random.choice(ln) for i in range(int(spin.get())))
else:
return(' - ')
pswd = ((30-int(spin.get()))//2)*' '+pswd
return(pswd)
window = Tk()
window.title("To Pswd")
window.resizable(width = False, height = False)
window.geometry('435x208')
window['bg'] = '#193019'
var1 = IntVar()
bt1 = Checkbutton(window, text='Нижний регистр ', variable=var1, onvalue=0, offvalue=1, bg='#A1ABB4')
bt1.place(x=0, y=0, width=120, height=25)
var2 = IntVar()
bt2 = Checkbutton(window, text='Верхний регистр', variable=var2, onvalue=0, offvalue=1, bg='#A1ABB4')
bt2.place(x=0, y=26, width=120, height=25)
var3 = IntVar()
bt3 = Checkbutton(window, text='Цифры ', variable=var3, onvalue=0, offvalue=1, bg='#A1ABB4')
bt3.place(x=0, y=52, width=120, height=25)
var4 = IntVar()
bt4 = Checkbutton(window, text='Спец. символы ', variable=var4, onvalue=0, offvalue=1, bg='#A1ABB4')
bt4.place(x=0, y=78, width=120, height=25)
label = Label(window, text='Длина от 1 до 30 ▼', bg='#A1ABB4', fg='black')
label.place(x=0, y=104, width=120, height=25)
g = StringVar(window)
g.set('12')
spin = Spinbox(window, from_=1, to=30, textvariable=g, bg='#A1ABB4')
spin.place(x=0, y=130, width=120, height=25)
bt5 = Button(window, text="Создать", command=tst)
bt5.place(x=0, y=156, width=120, height=51)
txt1 = Text(window)
txt1.place(x=155, y=0, width=245, height=25)
txt2 = Text(window)
txt2.place(x=155, y=26, width=245, height=25)
txt3 = Text(window)
txt3.place(x=155, y=52, width=245, height=25)
txt4 = Text(window)
txt4.place(x=155, y=78, width=245, height=25)
txt5 = Text(window)
txt5.place(x=155, y=104, width=245, height=25)
txt6 = Text(window)
txt6.place(x=155, y=130, width=245, height=25)
txt7 = Text(window)
txt7.place(x=155, y=156, width=245, height=25)
txt8 = Text(window)
txt8.place(x=155, y=182, width=245, height=25)
window.mainloop()