Skip to content

Instantly share code, notes, and snippets.

Created May 18, 2016 20:19
Show Gist options
  • Save anonymous/5ecf166057fb078784c19b11051ce626 to your computer and use it in GitHub Desktop.
Save anonymous/5ecf166057fb078784c19b11051ce626 to your computer and use it in GitHub Desktop.
from sys import argv
import random
import Tkinter
import tkFileDialog
from Tkinter import *
from ttk import *
from HTMLParser import HTMLParser
app = Tk()
app.title("text thingy")
app.resizable(0,0)
app.grid()
h = HTMLParser()
def writeToLog(msg):
logField['state'] = 'normal'
logField.insert('end', msg)
alphacodes = {'A': 'A', 'B': 'B', 'C': 'C', 'D': 'D', 'E': 'E', 'F': 'F',
'G': 'G', 'H': 'H', 'I': 'I', 'J': 'J', 'K': 'K', 'L': 'L', 'M': 'M',
'N': 'N', 'O': 'O', 'P': 'P', 'Q': 'Q', 'R': 'R', 'S': 'S', 'T': 'T',
'U': 'U', 'V': 'V', 'W': 'W', 'X': 'X', 'Y': 'Y', 'Z': 'Z', 'a': 'A',
'b': 'B', 'c': 'C', 'd': 'D', 'e': 'E', 'f': 'F', 'g': 'G', 'h': 'H',
'i': 'I', 'j': 'J', 'k': 'K', 'l': 'L', 'm': 'M', 'n': 'N', 'o': 'O',
'p': 'P', 'q': 'Q', 'r': 'R', 's': 'S', 't': 'T', 'u': 'U', 'v': 'V',
'w': 'W', 'x': 'X', 'y': 'Y', 'z': 'Z', ' ': ' '}
up_accents = ['̍', '̎', '̄', '̅', '̿', '̑', '̆', '̐', '͒', '͗',
'͑', '̇', '̈', '̊', '͂', '̓', '̈́', '͊', '͋', '͌', '̃', '̂',
'̌', '͐', '̀', '́', '̋', '̏', '̒', '̓', '̔', '̽', '̉', 'ͣ',
'ͤ', 'ͥ', 'ͦ', 'ͧ', 'ͨ', 'ͩ', 'ͪ', 'ͫ', 'ͬ', 'ͭ', 'ͮ', 'ͯ',
'̾', '͛', '͆', '̚']
down_accents = ['̖', '̗', '̘', '̙', '̜', '̝', '̞', '̟', '̠', '̤',
'̥', '̦', '̩', '̪', '̫', '̬', '̭', '̮', '̯', '̰', '̱', '̲',
'̳', '̹', '̺', '̻', '̼', 'ͅ', '͇', '͈', '͉', '͍', '͎', '͓',
'͔', '͕', '͖', '͙', '͚', '̣']
mid_accents = ['̕', '̛', '̀', '́', '͘', '̡', '̢', '̧', '̨', '̴',
'̵', '̶', '͏', '͜', '͝', '͞', '͟', '͠', '͢', '̸', '̷', '͡']
def convertstring():
logField.delete("1.0",END)
instr = queryStr.get()
newstringlist = []
# newstring = ""
for char in instr:
newchar = alphacodes[char]
newstringlist.append(newchar)
newstring = "".join(newstringlist)
escapedstring = h.unescape(newstring)
# writeToLog(newstring + "\n")
writeToLog(escapedstring)
app.update()
def garbagestring():
logField.delete("1.0",END)
instr = queryStr.get()
newstringlist = []
for char in instr:
up_count = random.randint(1,5)
mid_count = random.randint(1,3)
down_count = random.randint(6,23)
up_decorators = [random.choice(up_accents) for n in xrange(0, up_count)]
mid_decorators = [random.choice(mid_accents) for n in xrange(0, mid_count)]
down_decorators = [random.choice(down_accents) for n in xrange(0, down_count)]
decorators = [char] + up_decorators + mid_decorators + down_decorators
newstringlist.append("".join(decorators))
newstring = "".join(newstringlist)
escapedstring = h.unescape(newstring)
# writeToLog(newstring + "\n")
writeToLog(escapedstring)
app.update()
def quit():
app.destroy()
queryStr = StringVar()
Label(app,text="input text: ").grid(sticky=W,column=0,padx=5,pady=5,row=1)
queryEntry = Entry(app,textvariable=queryStr,cursor="xterm").grid(sticky=W,column=1,ipadx=100,padx=5,pady=2,row=1)
runbutton1 = Button(app,text="big text",width=25,state=ACTIVE,command=convertstring)
runbutton1.grid(sticky=W,column=2,padx=5,pady=2,row=1)
runbutton2 = Button(app,text="zalgo text",width=25,state=ACTIVE,command=garbagestring)
runbutton2.grid(sticky=W,column=2,padx=5,pady=2,row=2)
logField = Text(app,state='disabled',width=80,height=25,wrap='word')
logField.grid(sticky=W,column=0,columnspan=3,padx=5,pady=10,row=4)
logField.insert(END,"")
quitbutton = Button(app,text="Quit",width=25,command=quit).grid(sticky=W,column=2,padx=5,pady=10,row=5)
app.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment