Annotation of doc/help/latexSplitter.py, revision 1.1
1.1 ! bowersj2 1: """Latex Splitter quickee python app.
! 2:
! 3: This application assists in spliting large Latex files into lots of
! 4: smaller ones.
! 5:
! 6: To use this application, paste a latex file into the window. Highlight
! 7: the section you wish to save as an independent fragment. Then hit the
! 8: button, give the fragment a file name and a topic, and save
! 9: it. Continue until you've retreived everything out of the file you
! 10: want.
! 11:
! 12: Starting it with a command-line parameter will try to load that file
! 13: into the text box.
! 14:
! 15: This program may require Python as high as 2.2, though 2.1 should
! 16: do."""
! 17:
! 18: from Tkinter import *
! 19: from ScrolledText import *
! 20: import anydbm
! 21: import sys
! 22: import string
! 23:
! 24: dirprefix = "/home/httpd/html/adm/help/"
! 25:
! 26: class LatexSplitter:
! 27: def __init__(self, master):
! 28: self.frame = Frame(master)
! 29: self.frame.pack()
! 30:
! 31: self.label = Label(self.frame, text = "For documentation on"
! 32: "this program, consult the source code.")
! 33: self.label.pack()
! 34:
! 35: self.text = ScrolledText(self.frame, width=120, height = 40);
! 36: self.text.pack(fill = BOTH, expand = 1)
! 37:
! 38: self.l2 = Label(self.frame, text = "File Root Name (no .tex):")
! 39: self.l2.pack()
! 40: self.topic = Text(self.frame, width=60, height = 1)
! 41: self.topic.pack()
! 42:
! 43: self.button = Button(self.frame, text = "Split & Save", \
! 44: command = self.splitAndSave)
! 45: self.button.pack()
! 46:
! 47: if len(sys.argv) > 1:
! 48: f = file(sys.argv[1])
! 49: self.text.insert("1.0", f.read())
! 50: f.close()
! 51:
! 52: def splitAndSave(self):
! 53: selection = self.text.get("sel.first", "sel.last")
! 54: topic = string.strip(self.topic.get("1.0", "end"))
! 55: filename = dirprefix + string.replace(topic, " ", "_") + ".tex"
! 56:
! 57: try:
! 58: f = file(filename, 'w')
! 59: except:
! 60: return
! 61: f.write(selection)
! 62: f.close()
! 63:
! 64: self.topic.delete("1.0", END)
! 65: self.text.delete("sel.first", "sel.last")
! 66:
! 67: f = file("latexSplitterTempResults", 'w')
! 68: f.write(self.text.get("1.0", END))
! 69: f.close()
! 70:
! 71: root = Tk()
! 72: app = LatexSplitter(root)
! 73: root.mainloop()
! 74:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>