Re: how to convert VB scripts to Gnumeric python



OK, I've completed my sample application. It's a simple data collection program that gets the current bitcoin price and appends it to a spreadsheet. Appears to work so far
on Morten's updated version as of this morning.

It can be found at:

https://github.com/deanmccarron/gnumeric-python-examples/blob/master/python-gnumeric-example.py

In writing it I stumbled into at least one wish-list item, which is a blessed set of function calls for formatting row and column widths/heights. I played around with doing some kind of class inheritance on the workbook object to add file I/O using
methods, but my python-fu is weak.

I wrote in a pretty verbose commentary style, it should be fairly easy to follow what I'm doing. It's not especially pretty Python code, but it is exactly what I wished I had when I started down my VB to Gnumeric conversion more than a year ago. Hopefully this, the patches and the massive amount of work Morten on the introspection interface
as well as his examples will make life a lot easier for those that follow.


On 04/14/2018 08:52 AM, dm-gnome mercuryresearch com wrote:
Turned out the be a problem in my package builder -- I suspect I'm missing some part of the toolchain as the "@YELP_HELP_RULES@" line in the doc makefile was breaking with a missing separator warning.

This was added since 1.12.32, presumably installing yelp-tools will fix this?

Commented it out and I'm up an running. I also updated goffice for good measure.

basic and simple tests pass now with no issue. On io test I'm getting:

Traceback (most recent call last):
  File "t3002-introspection-io.py", line 25, in <module>
    wbv = Gnm.WorkbookView.new_from_uri (src_uri, None, ioc, None)
TypeError: constructor returned NULL

The plugin test is failing as well, but this is very likely due to me missing some components (I only use Gnumeric, not gnome) and this isn't an especially great concern in my use case.


On 04/14/2018 05:39 AM, Morten Welinder wrote:
So it's expected a Gnm.Cell and not the col, row provided in the program.
That's a sign you're picking up an old introspection file. "make install"
might help.

M.

On Fri, Apr 13, 2018 at 9:18 PM <dm-gnome mercuryresearch com> wrote:

Also using your test program, as is I get an error when it hits the
sheet.cell_set_value
operation, saying it got 3 variables instead of the 2 expected. When I
change it to two, I get:
TypeError: argument cell: Expected Gnm.Cell
So it's expected a Gnm.Cell and not the col, row provided in the program.

I suspect I'm probably testing a bit ahead of your patches on github.

On 04/13/2018 06:00 PM, dm-gnome mercuryresearch com wrote:
OK, I've updated from github (I installed goffice and gnumeric) and
I'm getting a crash on my application's file IO:

** (pubrep:23096): WARNING **: Couldn't connect to accessibility bus:
Failed to connect to socket /tmp/dbus-E0H2kRCBCm: Connection refused
shell to uri
workbook view from uri

** (pubrep:23096): CRITICAL **: go_doc_init_read: assertion
'doc->priv->imagebuf == NULL' failed
Segmentation fault

This appears to be happening on the line

s_wbv=Gnm.WorkbookView.new_from_uri(s_uri, None, io, None)

Which is the actual workbook file open read. Though this may just be
me (perhaps I need to update other libraries?)

This worked on goffice-0.10.32 with the patches I'd used on gnumeric.
So we'll need to sort out what changed.


On 04/13/2018 11:17 AM, Morten Welinder wrote:
Major progress on my end. I found two major sources of crashes (1:
many of our
boxed types were bad; 2: some pygobject versions fail on
transfer-full arguments).

You can follow the battle at
  Â
https://git.gnome.org/browse/gnumeric/tree/README-introspection
although that file may move. This file also contains the "blessed"
API.
This is still evolving.

My main test script is at
  Â

https://git.gnome.org/browse/gnumeric/tree/test/t3001-introspection-simple.py
It does pretty much everything one can do to a workbook other than
file i/o.
(That's somewhere on my list.)

Note: I have marked lots of functions as "skip" because they are
low-level functions
not intended for scripting. Most of GnmCell's methods are like
that.  They don't do
what you would expect of them and there are proper alternatives,
typically in Sheet.Â

Morten

_______________________________________________
gnumeric-list mailing list
gnumeric-list gnome org
https://mail.gnome.org/mailman/listinfo/gnumeric-list

_______________________________________________
gnumeric-list mailing list
gnumeric-list gnome org
https://mail.gnome.org/mailman/listinfo/gnumeric-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]