wxMenu problems

Susanne Lefvert wrote:

Hi,

I would like to build menu items dynamically when my program is running but I can not figure out what event to react on. I would like to add menu items to self.subMenu when a user clicks on self.submenu. I tried EVT_MENU_OPEN but that only works on linux. (From documentation: On Windows, this is only sent once for each navigation of the menubar (up until all menus have closed)). EVT_MENU_HIGHLIGHT only works for menu items not for menus. No success with EVT_UPDATE_UI either :frowning:

self.menubar = wxMenuBar()
self.SetMenuBar(self.menubar)

self.menu = wxMenu()
self.subMenu = wxMenu()
self.menu.AppendMenu(self.ID, "Submenu", self.subMenu)
self.menubar.Append(self.menu, "MainMenu")

If you have any ideas, please let me know.

You probably know before the menu is opened what items you would like to add to it, don't you? Why not add them then?

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Actually, the contents of the menu is read from a file and I want
to be able to update the menu if the file changed without having to close
down the program.

Thanks,

Susanne

···

On Mon, 15 Sep 2003, Robin Dunn wrote:

Susanne Lefvert wrote:
> Hi,
>
> I would like to build menu items dynamically when my program is running
> but I can not figure out what event to react on. I would like to add menu
> items to self.subMenu when a user clicks on self.submenu. I tried
> EVT_MENU_OPEN but that only works on linux. (From documentation: On Windows, this is
> only sent once for each navigation of the menubar (up until all menus have
> closed)). EVT_MENU_HIGHLIGHT only works for menu items not for menus.
> No success with EVT_UPDATE_UI either :frowning:
>
> self.menubar = wxMenuBar()
> self.SetMenuBar(self.menubar)
>
> self.menu = wxMenu()
> self.subMenu = wxMenu()
> self.menu.AppendMenu(self.ID, "Submenu", self.subMenu)
> self.menubar.Append(self.menu, "MainMenu")
>
>
> If you have any ideas, please let me know.
>

You probably know before the menu is opened what items you would like to
add to it, don't you? Why not add them then?

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

Hi Sussane,

I can't think of an event that will help you but..

I guess you mean that your programme needs
to change it's menu if *another* programme changes the
menu file.

If so,

what about a timer that checks your file at a certain
interval (you could check the time and date of the file)?

or

what about a check whenever your programme loses
focus and then gets it back again (you will have to activate
another programma to change the file I guess - (unless off
course you can change it using a network or otherwise))

Hope this helps,
Rob

···

16-09-2003 15:42:24, Susanne Lefvert <lefvert@mcs.anl.gov> wrote:

Actually, the contents of the menu is read from a file and I want
to be able to update the menu if the file changed without having to close
down the program.

Thanks,

Susanne