Re: using custom classes



sylvain wrote:
I'm sorry to disturb you again, but in your example, you're adding a menuitem in an existing menu, do you know how to create a new menu in the menubar ?

Thanks a lot :)


I'm replying to the list, so others can google for the info in the future. Hope you don't mind.

The menu definition is GtkUIManager UI definition file, see "http://developer.gnome.org/doc/API/2.0/gtk/GtkUIManager.html";. Scroll down to example 1.

In my plugin, the file is transpose.xml.

And 'Transpose' in these lines in Python:
transpose_ui_actions = {
        'Transpose': f_transpose,
}

matches     <menuitem action="Transpose"/>
in the UI definition file.

To make a new menu, you simply change

  <menu name="Tools" action="MenuTools">

in the UI definition file to
  <menu> name="Mine" action="AllMine">

(I hope - I didn't test)

the PyGtk documentation is at http://www.pygtk.org/pygtk2reference/. The Gtk documentation is at http://developer.gnome.org/doc/API/2.0/gtk/index.html. The documentation for the Python support in Gnumeric is at http://www.gnome.org/projects/gnumeric/doc/sect-extending-python.shtml.

Jon





------------------------------------------------------------------------
 > Subject: Re: using custom classes
 > From: hellan acm org
 > To: bw_syl hotmail com
 > CC: gnumeric-list gnome org
 > Date: Wed, 6 Dec 2006 21:46:29 +0100
 >
 > On Wed, 2006-12-06 at 20:42 +0100, sylvain wrote:
 > > Hi!!
 > >
 > > I'm trying to write a python plugin for gnumeric, i would like to know
 > > if it is possible to call a class in this type of plugin, for example,
 > > i would like to take information from a database and put it in some
 > > cells.
 > >
 > > And in addition is it possible to add a menu button to call this type
 > > of plugin functions.
 > >
 > > I hope i've been clear enough.
 > >
 > > Thank you.
 >
 > I put up an example with a menu item at
 > http://jk.ufisa.uninett.no/gnumeric/transpose.tgz
 > It's from 1.4, and I don't know how badly it's bitrotted, but there
 > haven't been big changes in this area since then.
 >
 > As to the first question, yes, your plugin can import other python
 > modules and call them.
 >
 > Jon Kåre
 >

------------------------------------------------------------------------
Essayez Live.com, votre nouvelle page d'accueil ! Personnalisez-la en quelques clics pour retrouver tout ce qui vous intéresse au même endroit. au même endroit. <http://www.live.com/getstarted>




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