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