[pygtk] Simple question on reusing stock item - SOLVED

Alessandro Dentella sandro at e-den.it
Tue Feb 10 02:50:21 WST 2009


On Mon, Feb 09, 2009 at 02:04:24AM -0800, John Finlay wrote:
> Alessandro Dentella wrote:
> > Hi,
> >
> >   i'd like to use stock item in menu entries with modified labels to better
> >   suit context.
> >
> >   *  MenuItem doesn't allow to use images (reasonable)
> >   *  ImageMenuItem doesn't appearently allow to change label (really???)
> >
> >   I think I could go with IconFactory but it seems to me it's more complex
> >   than what is should be and I wandered if there is a simple way I was not
> >   able to work out.
> >
> >   Thanks
> >   
> >   sandro
> >   *:-)
> >
> >   
> A MenuItem is a Container so you can add anything to it. In your case 
> create an empty MenuItem and add an HBox containing an Image and a Label.

Today pygtk FAQ is back (yesterday was not reachable) and I saw the solution
there. What I didn't imaginis that you can instantiate an ImageMenuItem as:

   item = gtk.ImageMenuItem('Foo')


even thought official docs say:

   gtk.ImageMenuItem(stock_id=None, accel_group=None)



More information about the pygtk mailing list