from tkinter import *
import random
root = Tk()
root.state('zoomed')
e1 = Entry(width=50)
e2 = Entry(width=50)
e1.delete(0, END)
e1.insert(0,"decription")
e2.delete(0, END)
e2.insert(0,"password")
def copytext():
root.clipboard_append(e2.get())
def callbackselect(event):
selection = event.widget.curselection()
data = event.widget.get(selection)
e1.delete(0, END)
e2.delete(0, END)
e2.insert(0,data)
def insert():
box_1.insert(END, e1.get())
box_2.insert(END, e2.get())
f1 = open('description.txt', 'a')
f1.write(e1.get() + '\n')
f2 = open('password.txt', 'a')
f2.write(e2.get()+ '\n')
box_1 = Listbox(selectmode=EXTENDED,width=40)
box_1.pack(side=LEFT,fill="both")
scroll_1 = Scrollbar(command=box_1.yview)
scroll_1.pack(side=LEFT, fill=Y)
box_1.config(yscrollcommand=scroll_1.set)
box_2 = Listbox(selectmode=EXTENDED)
box_2.pack(side=LEFT,fill="both")
scroll_2 = Scrollbar(command=box_2.yview)
scroll_2.pack(side=LEFT, fill=Y)
box_2.config(yscrollcommand=scroll_2.set)
box_2.bind("<<ListboxSelect>>", callbackselect)
f1 = open('description.txt',"r")
for line in f1:
print(line)
box_1.insert(END,line)
f1.close()
f2 = open('password.txt',"r")
for line in f2:
box_2.insert(END,line)
f2.close()
but_1 = Button(text="Добавить пароль", command=insert)
but_2 = Button(text="Копировать пароль в буфер обмена", command=copytext)
e1.pack()
e2.pack()
but_1.pack()
but_2.pack()
root.mainloop()
|