John K <john...@...> writes:
> I added the following to the Lyx external_templates file:
>
> Template Python
> GuiName "Python: $$AbsOrRelPathParent$$Basename"
> HelpText
> Python diagram.
> HelpTextEnd
> InputFormat "*"
I think you need to define an input format and a .py -> .pdf converter which
runs the python interpreter on your file.
> FileFilter "*.py"
> AutomaticProduction true
> Preview Graphics
> Format PDFLaTeX
> Product "\\includegraphics{$$AbsPath$$Basename.pdf}"
> Requirement "graphicx"
> UpdateCommand "python $$AbsPath$$Basename.py"
I haven't seen any description for "UpdateCommand" anywhere. Where does that
come from? It's not in the documentation, or?
> UpdateFormat pdf
> UpdateResult "$$AbsPath$$Basename.pdf"
> Requirement "graphicx"
> ReferencedFile pdflatex "$$AbsPath$$Basename.pdf"
> FormatEnd
> TemplateEnd
>
> However, when I insert the Python script in Lyx, it draws a box that says
"Error converting to loadable
> format".
Yes, because LyX doesn't know how to convert a python file to a graphics file.
Try the way I described above: defining the file format and converter under the
menu : Tools > Preferences... > File Handling.
Once you have that I believe it will work. In fact once you have that you could
simply use the graphics inset in the usual way to insert your .py file, that is,
no need for an external material template.
--
Julien