diff --git a/main.py b/main.py index 482e53e..f3d71fb 100755 --- a/main.py +++ b/main.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 -# Key Master v1.01 -# 04/09/2021 +# Key Master v1.02 +# 24/12/2021 # https://t.me/ssleg © 2021 import sqlite3 @@ -14,7 +14,7 @@ import cryptocode class LoginCard: - """класс хранения карточки логина/пароля""" + """Класс хранения карточки логина/пароля""" __slots__ = ['__row_id', '__encrypt_key', '__hash', '__name', '__login', '__password'] @@ -95,7 +95,7 @@ class LoginCard: class AllCards: - """класс хранения всех карточек""" + """Класс хранения всех карточек""" __slots__ = ['__encrypt_key', '__cards'] @@ -263,17 +263,19 @@ def system_init(): # окно ввода и проверки пароля def system_login(): + qt_enter_key1 = 'special 16777220' + qt_enter_key2 = 'special 16777221' attempts = 3 status = False password = '' layout = [[Sg.Text('Пароль:'), Sg.InputText(size=(20, 1), border_width=3, password_char='*')], [Sg.Button('Ok'), Sg.Text('', key='Err_text', text_color='firebrick1', font='style:bold')]] - window = Sg.Window("KeyMaster - вход", layout) + window = Sg.Window("KeyMaster - вход", layout, return_keyboard_events=True) while True: event, values = window.read() if event == Sg.WIN_CLOSED: break - if event == 'Ok': + if event == 'Ok' or event in ('\r', qt_enter_key1, qt_enter_key2): input_word = values[0] if len(input_word) >= 4: password = sha256(input_word.encode()).hexdigest() @@ -405,7 +407,8 @@ def main(): size=(20, 10), key='list'), Sg.Text(key='card')], [Sg.Button('Добавить'), Sg.Button('Редактировать', disabled=True, key='edit'), Sg.Button('Скопировать пароль', disabled=True, key='copy')], - [Sg.Button('Удалить', disabled=True, key='delete')]] + [Sg.Button('Удалить', disabled=True, key='delete'), Sg.Text(' '), + Sg.Button('Скопировать логин', disabled=True, key='copy_login')]] window = Sg.Window("KeyMaster - главная", layout) while True: event, values = window.read() @@ -417,6 +420,7 @@ def main(): if not keys_disabled: window.Element('edit').update(disabled=True) window.Element('copy').update(disabled=True) + window.Element('copy_login').update(disabled=True) window.Element('delete').update(disabled=True) keys_disabled = True @@ -434,6 +438,7 @@ def main(): if keys_disabled: window.Element('edit').update(disabled=False) window.Element('copy').update(disabled=False) + window.Element('copy_login').update(disabled=False) window.Element('delete').update(disabled=False) keys_disabled = False @@ -446,6 +451,12 @@ def main(): password = my_cards.get_card_password(name[0]) Sg.clipboard_set(password) + if event == 'copy_login': + name = window.Element('list').get() + if len(name) > 0: + login = my_cards.get_card_login(name[0]) + Sg.clipboard_set(login) + if event == 'edit': name = window.Element('list').get() if len(name) > 0: