from tkinter import *
from tkinter import ttk
import tkinter as tk
root = Tk()
root.title('Шифрование')
root.geometry('500x400')
def perevod():
alfavit = 'АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ'
key = 3
itog = ''
text = base.get()
for i in text:
if i in alfavit:
mesto = alfavit.find(i)
new_mesto = (mesto + key) % len(alfavit)
itog += alfavit[new_mesto]
else:
itog += i
lbll.config(text=itog)
base = tk.StringVar()
lbl = ttk.Label(root, text='Перевод в шифр', font='Arial 25')
lbl.pack()
lbl = ttk.Label(root, text='Введите текст', font='Arial 20')
lbl.pack()
name_entry = ttk.Entry(root, textvariable=base, font='Arial 25', width=20)
name_entry.pack()
btn = ttk.Button(root, text='Перевести', command=perevod)
btn.pack()
lbl = ttk.Label(root, text='Ответ: ', font='Arial 25')
lbl.pack()
lbll = ttk.Label(root, text='', font='Arial 25')
lbll.pack()
root.mainloop()
from tkinter import ttk
import tkinter as tk
root = Tk()
root.title('Шифрование')
root.geometry('500x400')
def perevod():
alfavit ='АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ'
key=3
itog = ''
base=tk.StringVar()
for i in base():
mesto = alfavit.find(i)
new_mesto = mesto + key
if i in alfavit:
itog += alfavit[new_mesto]
else:
itog += i
print(itog)
lbl = ttk.Label(root, text='Перевод в шифр', font='Arial 25')
lbl.pack()
lbl = ttk.Label(root, text='Введите текст', font='Arial 20')
lbl.pack()
name_entry=ttk.Entry(root,textvariable=base, text = '',font = 'Arial 25', width=1)
name_entry.pack()
btn = ttk.Button(root, text='Перевести',command=perevod)
btn.pack()
lbl = ttk.Label(root, text='Ответ: ', font='Arial 25')
lbl.pack()
lbll = ttk.Label(root, text='', font='Arial 25')
lbll.pack()
root.mainloop()