Python Shell
Anthony Dardis
adardis at gmail.com
Mon Jan 10 18:31:56 EST 2011
On Mon, 10 Jan 2011 17:04:50 -0500, Christoph Holtermann
<c.holtermann at gmx.de> wrote:
> Hello and a happy new year !
>
> My interest in gnucash is to have a python-shell-environment which lets
> me easily access and display
> data. I have written some things for myself like simple functions
> PrintTransaction(Transaction) and so for other objects.
>
> I use IPython for that purpose. I would like to submit my tries in that
> direction but for myself I would
> like to find the best solution for at least these printing functions
> before I do to not submit something
> too preliminary.
>
> I wonder in which way a function that prints an complex object should be
> done.
>
> When looking around in the internet i saw things like
> object.prettyPrint(). I came across
> object.__format__().
>
> When I print out for example a transaction i want to print out
> information of objects that are nested into
> it. For example I would probably also to print out the splits.
>
> I would like to have some function of the objects that are always called
> the same way. In the end I would
> like to have something as easy as
>
> print object.
>
> Could someone point me something helpful ?
How far into Python are you? It should be pretty easy to write an
interpreter for a very simple language like your last suggestion. You
would need to decide how you wanted it to work (how will you refer to the
objects?). Also, you would need to decide how fancy the environment should
be. For instance you could model what you want on IDLE, so there's a
prompt, and various commands defined under it. I think IDLE is written
using tkinter. I don't know what the best way to do GUI's in Python is;
there's a Gtk+ interface that's essentially the same as the c/c++
interface (http://www.pygtk.org/) (and Glade is supposed to work either
with c or with python). The object/method syntax is fine (a) if you know
it, and (b) you code ways to make Gnucash objects into Python objects
(object.prettyPrint() just calls the prettyPrint method on the value of
object, so you need to define that kind of object with its methods, and
set its data fields to be a Gnucash object).
More information about the gnucash-devel
mailing list