Re: Python

On Thu, 2003-12-04 at 05:16, pasty wrote:
 Not sure if this is the best place to ask these questions, but here goes.
 As new comer to Gnumeric, I'm trying hard to leave Microsoft's Excel 
behind.  Unfortunately, I've become rather reliant on a number of functions 
written in visual basic.  Transfering excel workbooks really means re- 
writing a number of functions.
 When adding user defined functions, is it best to write python plugin 
modules (as described in the help manual) or is there another method?
 If python plugins are the most suitable, is there a way of having gnumeric 
re-read the python plugin file without closing and re-opening?

Writing python plugin modules is the recommended method. There is a
plugin example at There is also
an example of a python plugin which adds some GUI, but this crashes
under Python 2.3. There has to be a memory management issue somewhere,
but I haven't had time to investigate.

It is unfortunately not possible to re-read the plugin file. You may
want to file an enhancement request in bugzilla.

Functions written in python plugin work real well.  It would be nice 
however, if Gnumeric could load a python function definition set written 
for a specific workbook, maybe embedded in the Gnumeric file, or saved to 
the same directory with the workbook's name and the .py file extension
 Can user defined functions be called by the button wigets?

Embedding python functions in workbooks would have security
implications. This was a popular virus vector for MS Office before email
worms became fashionable. It would be OK if we could be certain that we
could restrict the functions to a safe subset, but this is not possible
in Python. The Python developers have recently deprecated their
restricted execution modules, as they no longer were confident of its

Saving another file to the same directory does not sound so dangerous,
but where is the convenience?

Anyway, I agree that the current scheme is somewhat unwieldy.

There is an entry in the Gnumeric manual under extending Gnumeric called 
"defining new functions".  Is this page empty because the feature hasn't 
been documented yet, or because the feature hasn't been implemented yet.

New functions can be defined in Python and C. Doing it in Python is
documented, so this chapter is probably intended to explain how to do it
in C. Almost all functions which come with gnumeric are implemented in
plugins written in C. I guess that answers your question.


Jon Kåre

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