Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- #event handlers
- def btnPrintFrequencyClick(event):#Print letter frequency of input text
- pass
- def btnAutoPrintClick(event):#Print autogenerated text
- pass
- def ChooseEnglish(event):#no comments
- btnEnglish["state"] = "disabled"
- btnRussian["state"] = "normal"
- global AlphabetLength
- AlphabetLength = 26
- def ChooseRussian(event):#no comments
- btnRussian["state"] = "disabled"
- btnEnglish["state"] = "normal"
- global AlphabetLength
- AlphabetLength = 33
- def TxtInputClick(event):#click into the input box
- if TxtInput.get("1.0", "1.122") == "Введите текст (все символы, не входящие в алфавит выбранного языка, не будут учитываться в процессе шифровки/расшифровки).":
- TxtInput.delete("1.0", END)
- def TxtOutputClick(event):#click into the output box
- if TxtOutput.get("1.0", "1.21") == "Здесь будет результат":
- TxtOutput.delete("1.0", END)
- def IsEnglishLetter(letter):#checked, is letter from English
- if(ord(letter)>=65 and ord(letter)<=90) or (ord(letter)>=97 and ord(letter)<=122):#is it english letter
- return True
- return False
- def IsRussianLetter(letter):#checked, is letter from Russian
- if (ord(letter)==1025 or (ord(letter)>=1040 and ord(letter)<=1103) or ord(letter)==1105):#is it russian letter
- return True
- return False
- def EntWithThatClick(event):
- pass
- def EntWhatClick (event):
- pass
- def btnGoClick (event):#changed symbol in the preliminary text
- pass
- def btnCancelClick (event):#deleted preliminary text and output text
- pass
- AlphabetLength = 33
- #There is user interface######################################################
- root = Tk()
- root.title( "Шифр перестановками")
- root.geometry("1400x515+0+0")
- TxtInput = Text(root, width = 35, height = 36, bg = "white", fg= "black", wrap = "word")
- TxtInput.insert("1.0", "Введите текст (все символы, не входящие в алфавит выбранного языка, не будут учитываться в процессе шифровки/расшифровки).")
- TxtInput.bind("<Button-1>", TxtInputClick)
- #set focus bind
- TxtInput.pack(side = "left")
- TxtAlphabetFrequency = Text(root, width = 20, height = 36, bg = "white", fg= "black", wrap = "word")
- TxtAlphabetFrequency.insert("1.0", "Усреднённая частота использования букв в русском тексте: "
- " о - 10.983 \n"
- "е - 8.483 \n "
- "а - 7.998 \n "
- "и - 7.367 \n "
- "н - 6.7 \n "
- "т - 6.318 \n "
- "с - 5.473 \n "
- "р - 4.746 \n "
- "в - 4.533 \n "
- "л - 4.343 \n "
- "к - 3.486 \n "
- "м - 3.203 \n "
- "д - 2.977 \n "
- "п - 2.804 \n "
- "у - 2.615 \n "
- "я - 2.001 \n "
- "ы - 1.898 \n "
- "ь - 1.735 \n "
- "г - 1.687 \n "
- "з - 1.641 \n "
- "б - 1.592 \n "
- "ч - 1.45 \n "
- "й - 1.208 \n "
- "х - 0.966 \n "
- "ж - 0.94 \n "
- "ш - 0.718 \n "
- "ю - 0.638 \n "
- "ц - 0.486 \n "
- "щ - 0.361 \n "
- "э - 0.331 \n "
- "ф - 0.267 \n "
- "ъ - 0.037 \n "
- "ё - 0.013 \n ")
- #set focus bind
- TxtAlphabetFrequency.pack(side = "left")
- TxtInputTextFrequency = Text(root, width = 20, height = 36, bg = "white", fg= "black", wrap = "word")
- TxtInputTextFrequency.insert("1.0", "Частота вводимого текста: \n\n")
- #set focus bind
- TxtInputTextFrequency.pack(side = "left")
- frame1=Frame(root)
- frame1.pack(side='left', padx=10)
- frame2=Frame(frame1)
- frame2.pack(side='top', padx=10)
- btnRussian = Button(frame2, text="Русский язык", width=13, height=3, bg= "Silver", fg= "black")
- btnRussian.bind("<Button-1>", ChooseRussian)
- btnRussian.pack(side ='left', pady=4)
- btnRussian["state"] = "disabled"
- btnEnglish = Button(frame2, text="Английский язык", width=13, height=3, bg= "Silver", fg= "black")
- btnEnglish.bind("<Button-1>", ChooseEnglish)
- btnEnglish.pack(side ='right', pady=3)
- frame3=Frame(frame1)
- frame3.pack(side='top', padx=10)
- EntWhat = Entry(frame3, width=4, bg = "white", fg = "black", justify="center")
- EntWhat.insert(INSERT, "что")
- EntWhat.bind("<Button-1>", EntWhatClick)
- EntWhat.config(font =("Times", 16))
- EntWhat.pack(side = "left", pady= 10)
- btnGo = Button(frame3, text="-->", width=5, height = 1, bg= "Silver", fg= "black")
- btnGo.bind("<Button-1>", btnGoClick)
- btnGo.pack(side='left', padx=10)
- EntWithThat = Entry(frame3, width=4, bg = "white", fg = "black", justify="center")
- EntWithThat.insert(INSERT, "чем")
- EntWithThat.bind("<Button-1>", EntWithThatClick)
- EntWithThat.config(font =("Times", 16))
- EntWithThat.pack(side = "left", pady= 10)
- frame4 = Frame(frame1)
- frame4.pack(side='top', padx=10)
- btnPrint = Button(frame1, text="Рассчитать частоту", width=30, height = 5, bg= "Silver", fg= "black")
- btnPrint.bind("<Button-1>", btnPrintFrequencyClick)
- btnPrint.pack(side='top', padx=10)
- btnAutoPrint = Button(frame1, text="Вывести автовариант", width=30, height = 5, bg= "Silver", fg= "black")
- btnAutoPrint.bind("<Button-1>", btnAutoPrintClick)
- btnAutoPrint.pack(side='top', pady=10)
- btnCancel = Button(frame1, text="Отменить", width=30, height = 5, bg= "Silver", fg= "black")
- btnCancel.bind("<Button-1>", btnCancelClick)
- btnCancel.pack(side='top', pady=10)
- TxtOutput = Text(root, width = 35, height = 36, bg = "white", fg= "black", wrap = "word")
- TxtOutput.insert(INSERT, "Здесь будет результат")
- TxtOutput.bind("<Button-1>", TxtOutputClick)
- TxtOutput.pack(side = 'right')
- TxtOutput = Text(root, width = 35, height = 36, bg = "white", fg= "black", wrap = "word")
- TxtOutput.insert(INSERT, "Здесь будет автовариант")
- TxtOutput.bind("<Button-1>", TxtOutputClick)
- TxtOutput.pack(side = 'right')
- ########################################################
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement