Skip to content

Instantly share code, notes, and snippets.

@Der-Eddy
Created January 19, 2018 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Der-Eddy/de2c1182924132b3abac74c79409534d to your computer and use it in GitHub Desktop.
Save Der-Eddy/de2c1182924132b3abac74c79409534d to your computer and use it in GitHub Desktop.
Paragraph Sorter
from tkinter import *
def sortText():
text = T.get(1.0, END)[:-2]
lst = text.split('\n\n')
lst.sort()
print(lst)
T.delete(1.0, END)
T.insert(END, '\n\n'.join(lst))
root = Tk()
S = Scrollbar(root)
T = Text(root, height=50, width=150)
B = Button(root, text='Sort', command=sortText, width=50)
S.pack(side=RIGHT, fill=Y)
T.pack(side=TOP, fill=Y)
B.pack(side=BOTTOM)
S.config(command=T.yview)
T.config(yscrollcommand=S.set)
mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment