"Alex Vergara Gil" <a...@cphr.edu.cu> writes: > From: Richard Heck > Sent: Thursday, May 29, 2014 3:26 PM > > > On 05/29/2014 03:36 PM, Alex Vergara Gil wrote: > > Hello Lyxers > > I wonder why LyX is not available to process little pieces of > python code within its own framework, like ipython notebook for > instance?? > > > This feature allows us to have beautiful graphics such the one > produced by matplotlib package. I know there already exists a > similar binding for R through knitr module, so why not a binding > for python too?? > > Is there a way, like modules or whatever, to achieve the same > functionality or at least some basic functionality of ipython notebook > within LyX?? Can you be more precise about what you want to do? I've > never heard of ipython notebook. sudo aptitude install > ipython-notebook ipython notebook > > and there you can write even thesis in a web environment with python > commands being executed inlined, exporting to pdf and latex too, it is > a wonder of our times, so why not letting LyX do this miracle too?? > > Sweave works by our having an output format (sweave) for such > documents and then our declaring Rscript as a sweave --> LaTeX > converter, so PDF export (say) goes via Rscript and > pdflatex. There's a special script in lib/scripts/ that "sets up > some things for LyX" first, or so it claims. It would be reasonably > easy to do the same sort of thing for Python, if you wanted to do > so. You'd just need to set up an appropriate format and then declare > an appropriate script as a whatever -> latex converter. Then LyX > will run the script and do as you wish with the embedded python > code. > > Of course, as we've discussed on the list with respect to R, there are > large security issues here, too. > > Richard you obviously miss the point here, or I was not very clear! > it is not a different format, is a facility to have python scripts > running within LyX framework, you have to see ipython notebook to > understand what I mean, you will be surprised!! Basically to build > graphs, for instance (and only a piece of what can be done), you add > the (let's call it) "knitpy" module and then place a knitpy insert, > write some python code that produces a matplotlib graphic and then > when lyx compiles the document, instead of the code it is shown the > graph, it also can be done in the lyx editing window, but thats a more > dificult request.
I might be *completely* off, but couldn't you achieve exactly this via defining converters? I have for example a converter defined, which "converts" plantuml source fields into uml graphs, i.e. it defines the call to compile them and return the graphs which are then inserted in the document? I have never used python, but I guess a similar approach should be possible here as well? Cheers, Rainer > > Regards > Alex -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Stellenbosch University South Africa Tel : +33 - (0)9 53 10 27 44 Cell: +33 - (0)6 85 62 59 98 Fax : +33 - (0)9 58 10 27 44 Fax (D): +49 - (0)3 21 21 25 22 44 email: rai...@krugs.de Skype: RMkrug PGP: 0x0F52F982
pgpNzrUAU7G2A.pgp
Description: PGP signature