[pygtk] Changing Menu titles(multi-language support)

A. B. aboufer@atlsci.com
Mon, 28 Oct 2002 09:28:20 -0500


Greetings all,

I am trying to implement multi-language support for a top menu but
so far I had no success.
Here is a some code to illustrate the problem:

Thanks for your time and help,

#------------------------------------------------
import gtk

MENU_FACT = None

def foo( *args ) :
    gtk.mainquit()

def bar( menuId, menuItem ) :
    global MENU_FACT
    fileMenu = MENU_FACT.get_widget( "<main>/File" )
    # I thought this should change the title from
    # File to Bonjour, but this does not happen! :-(
    #
    print "Trying to change to French!!!"
    fileMenu.set_title( "Bonjour" )


win  = gtk.GtkWindow()
win.connect( "delete-event", foo )
accel = gtk.GtkAccelGroup()
win.add_accel_group( accel )

menuFact = gtk.GtkItemFactory( gtk.GtkMenuBar, "<main>", accel )
MENU_FACT = menuFact
menuItems = [
    ('/_File'           , None, None, 0, '<Branch>'    ),
    ('/_File/Fr_ench'   , None, bar , 0, ''            ), ]

menuFact.create_items( menuItems )

mainBox = gtk.GtkVBox(spacing=10)
win.add( mainBox )
mainBox.pack_start( menuFact.get_widget("<main>") )

win.show_all()

gtk.mainloop()
#--------------------------------------------------