File:  [LON-CAPA] / doc / help / latexSplitter.py
Revision 1.1: download - view: text, annotated - select for diffs
Fri Jul 5 16:12:30 2002 UTC (22 years, 4 months ago) by bowersj2
Branches: MAIN
CVS tags: version_0_99_1, version_0_99_0, version_0_6_2, version_0_6, version_0_5_1, version_0_5, conference_2003, HEAD
This commit implements the .tex-based online help system in LON-CAPA. It
may be necessary to manually run loncom/build/help_graphics_converter.pl
and doc/help/rebuildLabelHash.pl after a cvs update, and
loncapa_apache.conf may need to be manually copied to /etc. (The
loncapafiles.lpml has been updated.)

After merging this, the URL http://[loncapahost]/adm/help/Foils.hlp
should display a help file.

Also, some *very* out-of-date files have been removed from the /doc
directory.

"""Latex Splitter quickee python app.

This application assists in spliting large Latex files into lots of
smaller ones.

To use this application, paste a latex file into the window. Highlight
the section you wish to save as an independent fragment. Then hit the
button, give the fragment a file name and a topic, and save
it. Continue until you've retreived everything out of the file you
want.

Starting it with a command-line parameter will try to load that file
into the text box.

This program may require Python as high as 2.2, though 2.1 should
do."""

from Tkinter import *
from ScrolledText import *
import anydbm
import sys
import string

dirprefix = "/home/httpd/html/adm/help/"

class LatexSplitter:
    def __init__(self, master):
        self.frame = Frame(master)
        self.frame.pack()

        self.label = Label(self.frame, text = "For documentation on" 
                           "this program, consult the source code.")
        self.label.pack()

        self.text = ScrolledText(self.frame, width=120, height = 40);
        self.text.pack(fill = BOTH, expand = 1)

        self.l2 = Label(self.frame, text = "File Root Name (no .tex):")
        self.l2.pack()
        self.topic = Text(self.frame, width=60, height = 1)
        self.topic.pack()

        self.button = Button(self.frame, text = "Split & Save", \
                             command = self.splitAndSave)
        self.button.pack()

        if len(sys.argv) > 1:
            f = file(sys.argv[1])
            self.text.insert("1.0", f.read())
            f.close()

    def splitAndSave(self):
        selection = self.text.get("sel.first", "sel.last")
        topic = string.strip(self.topic.get("1.0", "end"))
        filename = dirprefix + string.replace(topic, " ", "_") + ".tex"

        try:
            f = file(filename, 'w')
        except:
            return
        f.write(selection)
        f.close()

        self.topic.delete("1.0", END)
        self.text.delete("sel.first", "sel.last")

        f = file("latexSplitterTempResults", 'w')
        f.write(self.text.get("1.0", END))
        f.close()

root = Tk()
app = LatexSplitter(root)
root.mainloop()


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>