scripting

John Ralls jralls at ceridwen.us
Fri May 20 10:23:43 EDT 2016


> On May 20, 2016, at 5:26 AM, yary <not.com at gmail.com> wrote:
> 
> On Fri, May 20, 2016 at 2:52 AM, Colin Law <clanlaw at gmail.com> wrote:
>> On 19 May 2016 at 22:27, Don Ireland <gnucash at donireland.com> wrote:
>>> ...
>>> 
>>> Related Q: is it possible to write a script that interacts with GC while
>>> it's running? I'm thinking about an event handler that fires when performing
>>> certain tasks.
>> 
>> I don't see how that is related to how the data are stored.
> 
> Not sure about scripting a running GnuCash instance.
> 
> You can use the API to read and manipulate the data in your own
> program. And if the data is stored in a database format, and the
> database supports triggers, then you can have the database run code
> when data changes in a certain way. I would not try changing the
> database (or the XML representation) of a running instance behind its
> back, I'd only use triggers for reporting, logging, or writing to some
> different system.

There are numerous hooks and events in GnuCash for triggering actions, and there's a Scheme interpreter running, so if what you want to do can be triggered by an existing hook you can register your Scheme code to that hook. The same capability exists in theory for Python, though it's a bit more work and requires building with --enable-python. There's an example python console in src/python/pycons.

None of this is documented so you'll have to study the code and the developer docs (http://code.gnucash.org/docs/MAINT) to learn how to add your scripts.

Regards,
John Ralls




More information about the gnucash-user mailing list