Encoding text

As my notepad program now has an option to encode text using ROT13,  I have written a very basic (and rough) program to just do that.

The program is very basic,  and just encodes the text,  the code is as follows:

For reference the original code can be found here.

#rot 13 encoding
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
#!/usr/bin/env python
 
import random
import Tkinter # note use of caps
from Tkinter import *
 
LOWER_LETTERS = [chr(x) for x in range(97, 123)];
UPPER_LETTERS = [chr(x) for x in range(65, 91)];
 
def rot13():
	#print ("rot 13 encoding")
	sourceString = innotetext.get('1.0', END+'-1c')
	#print sourceString
	resultString = "";
	for char in sourceString:
		if char.isupper():
			resultString += encrypt(char, UPPER_LETTERS);
		elif char.islower():
			resultString += encrypt(char, LOWER_LETTERS);
		else:
			resultString += char;
	#print("The rot13 string is:%s" % (resultString));	
	#txt.delete(1.0, END)
	outnotetext.insert(END, resultString)
 
def encrypt(char, letterList):
    resultchar = '';
    originalIndex = letterList.index(char)
    newIndex = originalIndex + 13
    resultchar += letterList[newIndex % len(letterList)]
    return resultchar	
 
 
#set up
window = Tk()
window.title('Encoding')
window.geometry("800x250") #wxh
window.resizable(0,0)
 
 
#define labels - cannot share same name as function
box1 = Label(window, text="Text: ")
box2 = Label(window, text="Encoded: ")       
 
#place labels
box1.grid(row = 1, column = 1, padx = 5, pady = 5)
box2.grid(row = 3, column = 1, padx = 5, pady = 5)
 
#define text entry box
innotetext = Text(window, height=5, width=200)
#display text entry box
innotetext.grid(row = 1, column = 4,)
 
#define output
#define text out
outnotetext = Text(window, height=5, width=200)
#display text out
outnotetext.grid(row = 3, column = 4,)
 
#define buttons
 
response = Button( window, text ='Encode', command=rot13)
exitbtn = Button( window, text ='Exit', command=exit)
 
#place buttons
 
response.grid(row = 6, column = 1, padx = 1, pady = 1)
exitbtn.grid(row = 7, column = 1, padx = 1, pady = 1)
 
 
 
#display window
 
window.mainloop()

 

The program is more proof of concept,  however it does highlight how this feature works,  it can be adapted.