I’m adding a menu to my Enthought Traits/UI GUI application, like so:
<code># Main window layout definition.
traits_view = View(
Group(
{snip}
),
menubar=MenuBar(
Menu(
Action(name="Load Config.", action="do_load_cfg", accelerator="Ctrl+O"),
Action(name="Load Results", action="do_load_data"),
Separator(),
Action(name="Save Config.", action="do_save_cfg", accelerator="Ctrl+S"),
Action(name="Save Config. As...", action="do_save_cfg_as", accelerator="Ctrl+Shift+S"),
Action(name="Save Results", action="do_save_data"),
Separator(),
Action(name="&Quit", action="close_app", accelerator="Ctrl+Q"), # CloseAction()
id="file",
name="&File",
),
{snip}
),
)
</code>
<code># Main window layout definition.
traits_view = View(
Group(
{snip}
),
menubar=MenuBar(
Menu(
Action(name="Load Config.", action="do_load_cfg", accelerator="Ctrl+O"),
Action(name="Load Results", action="do_load_data"),
Separator(),
Action(name="Save Config.", action="do_save_cfg", accelerator="Ctrl+S"),
Action(name="Save Config. As...", action="do_save_cfg_as", accelerator="Ctrl+Shift+S"),
Action(name="Save Results", action="do_save_data"),
Separator(),
Action(name="&Quit", action="close_app", accelerator="Ctrl+Q"), # CloseAction()
id="file",
name="&File",
),
{snip}
),
)
</code>
# Main window layout definition.
traits_view = View(
Group(
{snip}
),
menubar=MenuBar(
Menu(
Action(name="Load Config.", action="do_load_cfg", accelerator="Ctrl+O"),
Action(name="Load Results", action="do_load_data"),
Separator(),
Action(name="Save Config.", action="do_save_cfg", accelerator="Ctrl+S"),
Action(name="Save Config. As...", action="do_save_cfg_as", accelerator="Ctrl+Shift+S"),
Action(name="Save Results", action="do_save_data"),
Separator(),
Action(name="&Quit", action="close_app", accelerator="Ctrl+Q"), # CloseAction()
id="file",
name="&File",
),
{snip}
),
)
But, I’m not getting the ordering of menu items correct (i.e. – as ordered in my code above) in the application GUI.
Instead, they’re showing up in (almost) reverse alphabetical order:
<code>Save Config.
Save Config. As...
Save Results
==================
Quit
==================
Load Config.
Load Results
</code>
<code>Save Config.
Save Config. As...
Save Results
==================
Quit
==================
Load Config.
Load Results
</code>
Save Config.
Save Config. As...
Save Results
==================
Quit
==================
Load Config.
Load Results
How do I explicitly control the ordering of the menu items in my Traits/UI GUI application?