So I made an GUI in python and encryption program: This is the layout
layout=[[sg.Text('Enter message'),sg.Input(key='-IN-')],
[sg.Text('Cryptation key'),sg.Input(key='-KEY-')],
[sg.Text('Answer',key='-OUT-')],
[sg.Button('OK'), sg.Button('EXIT')]
]
This is the while loop:
while True:
event, values=window.read()
if event is None or event == 'EXIT':
break
mesaj=str('-IN-').upper()
cheie=str('-KEY-').upper()
key=generate_key(mesaj,cheie)
encrypt_text=encrypt_vigenere(mesaj,key)
window['-OUT-'].update(values[encrypt_text])
window.close()
Here is the function that I think is thee problem:
def encrypt_vigenere(message,key_word):
key = generate_key(message,key_word)
encrypted_text = ""
for i in range(0,len(message)):
if message[i] == " ":
encrypted_text += " "
else:
encryption_value = (alphabets.find(message[i]) + alphabets.find(key[i]))%26
encrypted_text += alphabets[encryption_value]
return encrypted_text
And it gives me this error:
Traceback (most recent call last): File "C:/Users/flavius/Documents/python/games/urs_mina/main.py", line 62, in window['-OUT-'].update(values[encrypt_text]) KeyError: 'YSRX'
Every time I press OK ti shows the message above. Can someone explain to me why?