Difference between revisions of "Python Bindings"

From GnuCash
Jump to: navigation, search
(setting things up)
(setting things up)
Line 7: Line 7:
 
  export PYTHONPATH=$PYTHONPATH:/export/gnucash/lib/python2.5/site-packages
 
  export PYTHONPATH=$PYTHONPATH:/export/gnucash/lib/python2.5/site-packages
  
This adds the gnucash python bindings to your PYTHONPATH assuming that your gnucash resides in /export/gnucash
+
This adds the gnucash python bindings to your PYTHONPATH assuming that your gnucash resides in /export/gnucash.  You can then either start up an interactive python session with ipython or call your script to be executed.
  
  gnucash-env
+
  gnucash-env ipython
  ipython
+
  gnucash-env python $scriptyouwanttorun
 
 
gnucash-env sets up the environment and ipython is the interactive python shell.  All commands will be entered in that shell from now on.  Of course you could just as well run any gnucash python script from this point on.
 
  
 
= Documentation =
 
= Documentation =

Revision as of 10:33, 24 July 2008

Python bindings have been recently added to gnucash. There is still very little documentation and probably few people would know how to use it. While not a manual, this page was created in the hope to provide information for those interested in gnucash and python.

setting things up

I use ipython for an interactive shell. If you prefer something else, let us know if there is any difference.

export PYTHONPATH=$PYTHONPATH:/export/gnucash/lib/python2.5/site-packages

This adds the gnucash python bindings to your PYTHONPATH assuming that your gnucash resides in /export/gnucash. You can then either start up an interactive python session with ipython or call your script to be executed.

gnucash-env ipython
gnucash-env python $scriptyouwanttorun

Documentation

As pointed out in the introductory paragraph, the documentation is rather slim at this point in time. Here are some sources where you might be able to find what you are looking for. Generally speaking, this is not yet end-user friendly stuff.

  • example scripts from the source code
  • inside ipython
    • big long list of stuff
      • import gnucash.gnucash_core_c
      • help(gnucash_core_c)
      • dir(gnucash_core_c)
    • higher abstraction level help
      • import gnucash.gnucash_core
      • import gnucash.gnucash_business
      • help(gnucash.gnucash_core)
      • help(gnucash.gnucash_business)