Menu sorting

I would like to have my menus sorted by the "Text" of the menu items. The application uses gettext to translate the "Text" into different languages.

I would appreciate any hints on how to accomplish this. Could snippets would be great, but any hints would help me at this point.

Werner

You could do something like this:

# The entries
menuEntries = [ _('A'), _('C'), _('B') ]
# Sort them, if you want a differently sorted list, use the cmp argument to the sort function
menuEntries.sort()

# Create the menu
menu = wx.Menu()

# For each entry in the list
for entry in menuEntries:
     menu.Append( id, entry, 'Help text' ) )
menuBar.Insert( 0, menu , ... )

ยทยทยท

Am Mon, 15 May 2006 11:28:34 +0200 hat Werner F. Bruhin <werner.bruhin@free.fr> geschrieben:

I would like to have my menus sorted by the "Text" of the menu items. The application uses gettext to translate the "Text" into different languages.

I would appreciate any hints on how to accomplish this. Could snippets would be great, but any hints would help me at this point.