Re: how to convert VB scripts to Gnumeric python
- From: dm-gnome mercuryresearch com
- To: Morten Welinder <mortenw gnome org>, dm-gnome mercuryresearch com
- Cc: Gnumeric Mailing List <gnumeric-list gnome org>
- Subject: Re: how to convert VB scripts to Gnumeric python
- Date: Fri, 13 Apr 2018 11:53:36 -0700
I think with the changes made to function definitions from the patch
you've incorporated
into workbook-view.c file I/O should be functional, since they're the
identical to a known
functional code on my end.
The blessed API call list will be quite helpful! It'll be nice to know
where not to poke Gnumeric.
I'm looking forward to trying out the copy/paste, particularly if it
functions across workbooks.
At this point I think I think it's more appropriate for me to pull
Morten's latest changes and do any work against that, and anyone that
wants to develop in Python against gnumeric should do the same. I'll
work on getting an example done today but the pull and build may slow me
down a bit. Morten's example will render a lot of this moot, but I think
a practical sample is probably still useful to some.
Thanks for all your work on this, Morten! Not having to maintain my own
copy of Gnumeric plus getting all these features functional without
workarounds is going to make life a _lot_ easier for me (and everyone else!)
Since your test program is already well ahead of my sample, here's the
core file open and save routines from my application for inspiration,
some of which I already pasted. You probably know this better than I:
Gnm.init()
GOffice.init()
cc=Gnm.CmdContextStderr.new()
io=GOffice.IOContext.new(cc)
Gnm.plugins_init(cc)
s_uri=GOffice.shell_arg_to_uri("/your/file/path")
s_wbv=Gnm.WorkbookView.new_from_uri(s_uri, None, io, None)
s_wb = Gnm.wb_view_get_workbook(s_wbv)
for file save (reuses the cc from above):
# Save as new file
new_uri=GOffice.shell_arg_to_uri("/your/destination/path")
new_wbv=Gnm.WorkbookView.new(s_wb)
new_fs=GOffice.FileSaver.for_file_name(new_uri)
Gnm.wb_view_save_as(new_wbv,new_fs,new_uri,cc)
Of course you need to do a "from gi.repository import GOffice" and in my
application I import GLib as well, but I haven't tested to see if that's
strictly necessary for just file I/O. I don't believe the plugins_init
above is strictly necessary either, but it was for my application.
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]