On Thu, May 08, 2014 at 11:47:34PM -0700, mshapiro wrote: > David Osguthorpe wrote > > I have a very hacky implementation in gnucash to call python from guile > > and > > return results to guile - I found existing libraries to do both > > (no updates to gnucash required - just a user prototype.scm file) > > Can you post what libraries you used, where you got them, how to use them > and your prototype.scm file. Also, any pointers to useful documentation for > using the Python bindings would be greatly appreciated. I am primarily > interested (at the moment) in accessing budgeting information and future > transactions, as well as accounts, since I would like to do more forecasting > than the standard reports provide. >
it is really hacky - and I still had crashes when attempting to create real reports so its very, very alpha but if you wish to pursue it here are the details note this does not use any of the python bindings - as far as I can tell they only work for non-gui standalone scripts - well its the only Ive used them - you would write a script to access your gnucash database (xml or SQL) and use any python modules to format the data for a new report completely outside of gnucash for the moment I would say you would be better just writing command line scripts using the python bindings to generate HTML or whatever reports here are some details 1. you need pyguile - a module for calling guile version of scheme from python - unfortunately the available source has not been udpated for years so needed quite a bit of patching to build (I run under macports on OSX mainly) - one patch I did have to add was the ability to return so called SCM (scheme) objects back to guile 2. you need schemepy - which has a module for calling python from guile version of scheme - again the available source has not been udpated for years so needed some patching to get running Then you have the prototype.scm (simply not bothered to change name) which sets up to call python where you could write your report. My initial goal was to write reports in python - Im primarily writing in this now and although I had tried scheme for a multiple stock price scatter plot report every time I went back trying to re-think in scheme was a pain The major problem I ran across is that when analysing the GUI report system in gnucash I discovered it was not done in pure gtk but some of the gui is actually written in scheme by calling gtk gunctions via swig wrapped functions involving gtk - to directly call python reports would need re-writing most of this GUI scheme stuff using the python gtk library - not difficult but seemed like a lot of work I had hoped to find a report function where I could plugin in a call to python so could then do the report in python (python has the ctypes module which allows calling C functions in arbitrary C shared libraries such as gnucash uses) - pygtk allows direct use of gtk functions in python I did this around 2.4.7 and am looking to review it now at 2.6.3 from that analysis as far as I could tell the final report result is an html text string which is written to a file - again these components using scheme coding If you really want the files let me know as you have discovered there isnt much documentation of the python bindings I have some scripts and gnucash binding extensions - Ive been updating them because of the changes between 2.4 and 2.6 - I tend to use lots of comments to document what I discover as I use the bindings - youre welcome to them as well (I also have some updates to the swig bindings which my extensions/script use which I have not posted as patches because still figuring the changes from 2.4 to 2.6) David _______________________________________________ gnucash-devel mailing list gnucash-devel@gnucash.org https://lists.gnucash.org/mailman/listinfo/gnucash-devel