tags:

views:

138

answers:

1

I need to change the display text of a MenuItem. Is there any way of doing this without removing the MenuItem and then adding another one with a different text?

+3  A: 

It somewhat depends how you created the menu item, since a MenuItem is a container that can contain anything. If you created it like:

menuitem = gtk.MenuItem('This is the label')

Then you can access the label widget in the menu item with:

label = menuitem.child

And can then treat that as a normal label:

label.set_text('This is the new label')

However, unless you made the menu item yourself, you can't guarantee that the child widget will be a label like this, so you should take some care.

Ali A