On Tuesday 25 June 2002 11:44 pm, James Henstridge wrote:
> Gary Jaffe wrote:

[snip ...]

> >I can't figure out how to address the individual menu items stored in
> >the tuple of tuples that is used in the create_items method of the item
> >factory, so that I can set_sensitive(gtk.FALSE) for some of them.
>
> You can use the item factory's get_item() method, passing in the path to
> the menu item you are interested in.  You can then do what ever you want
> to the menu item (enable/disable it, show/hide it, etc).
>
Thanks for responding to my problem.

Sorry for being so dense, but I can't seem to get this to work.  I am using 
pygtk 0.6.6-7 and libgtk-1.2 on a Redhat 7.1 system.  My code for the menu 
looks something like this:

menu_items = (
        ( "/_File", None, None, 0, "<Branch>" ),
        ( "/File/_Save", "<control>S", self.saveEvent, 0, None ),
)
accelGrp = gtk.GtkAccelGroup()
itemFac = gtk.GtkItemFactory(gtk.GtkMenuBar.get_type(), "<main>", accelGrp)
mainWin.add_accel_group(accelGrp)
menuBar = itemFac.get_widget("<main>")

The above works fine.  Then I tried something like

editItem = itemFac.get_item("/File/_Save")

so that I could do

editItem.set_sensitive(gtk.FALSE)

but I got an 'AttributeError: get_item' on the first of these last 2 lines.

I obviously didn't quite get your explanation.  I would be greatful if you 
could correct my example code so that it will work.

Thanks again,

Gary
[EMAIL PROTECTED]
_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to