from Tkinter import * from string import * import os class Application(Frame): def __init__(self, master=None): Frame.__init__(self, master) self.grid(padx=4, pady=4, sticky=NW) self.createWidgets() def createWidgets(self): # Draw Widgets self.patchme = Button (self, text="Outline", command=self.testing) self.patchme.grid(row=2, column=0, columnspan=2, pady=7) self.textstatus = Text(self) self.textstatus.grid(row=1, column=0, columnspan=2, pady=6) def testing(self): currentIndex = 0 text = self.textstatus.get('1.0', END) self.textstatus.delete(1.0, END) splitText = text.splitlines(1) totalLength = len(splitText) headers = [] for i in range(0, totalLength): splitWords = splitText[i].split() if len(splitWords) > 0: firstWord = splitWords[0] if firstWord.find(".") > 0: headers.append(splitText[i]) # Had to add this case for situations where the page # numbers happened to be the first split. if len(splitWords) > 1: secondWord = splitWords[1] if secondWord.find(".") > 0: # Remove the troublesome page number del splitWords[0] headers.append(" ".join(splitWords)) #print "The discovered headers:" for item in headers: #print item self.textstatus.insert(END, item) app = Application() app.master.title("Law Review Outliner") app.mainloop()