I would like to change the Text of a Menu in a Menubar. But there is a problem. When a wxMenu is usually created, no ID needs to be passed. When then that menu is appended to a menubar, no ID can be passed either. However, if I wanted to change the Label (or Text, what is the difference?) with the SetLabel() method, I need to pass an ID and the new text. Where can I get the ID from ?
I would like to change the Text of a Menu in a Menubar. But there is a problem. When a wxMenu is usually created, no ID needs to be passed. When then that menu is appended to a menubar, no ID can be passed either. However, if I wanted to change the Label (or Text, what is the difference?) with the SetLabel() method, I need to pass an ID and the new text. Where can I get the ID from ?
If you are not using nested menus, you can use MenuBar.FindMenuItem to get the ID. If the menu is nested you'll need to call FindMenuItem or FindMenu on the menubar, followed by a succession of GetSubMenu and FindItem calls on the returned MenuItems till you get the one you want. You may just want to pick up menufuncs.py from http://starship.python.net/crew/hochberg/. Then you can do:
Even if you don't want to use it, it will give you an example of using FindMenuItem and friends.
-tim
···
peter
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org
It's funny though, in my opinion, that you can create something without any identifier, and if you want to change a property of it later, you need an identifier.
Shouldn't it rather work like
menu = wxMenu()
menu.SetLabel("Label")
or
ID = wxNewId()
menu = wxMenu(ID)
menu.SetLabel(ID,"Label")
It's funny though, in my opinion, that you can create something without any identifier, and if you want to change a property of it later, you need an identifier.
Shouldn't it rather work like
menu = wxMenu()
menu.SetLabel("Label")
or
ID = wxNewId()
menu = wxMenu(ID)
menu.SetLabel(ID,"Label")
It looks like I didn't read your original message closely enough. You want to change to title of the Menu in the menubar, not text in any of the submenus, is that right? In that case, you just want MenuBar.SetLabelTop(pos, label). This takes the positiion (0, 1, 2, ...) of the menu that you want to rename, not an ID.
Sorry for any confusion.
-tim
···
peter
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org
It looks like I didn't read your original message closely enough. You want to change to title of the Menu in the menubar, not text in any of the submenus, is that right?
That's right. However, I also have some submenus to change.
In that case, you just want MenuBar.SetLabelTop(pos, label). This takes the positiion (0, 1, 2, ...) of the menu that you want to rename, not an ID.
So the problem is only shifted. I need to store something away which should come from the Object creation, or the object creation should ask for in the first place.
As I said, I think that the way how Labels of menus are changed is not consistent.
peter
I would like to change the Text of a Menu in a Menubar. But there is a problem. When a wxMenu is usually created, no ID needs to be passed. When then that menu is appended to a menubar, no ID can be passed either. However, if I wanted to change the Label (or Text, what is the difference?) with the SetLabel() method, I need to pass an ID and the new text. Where can I get the ID from ?
You don't need it. To change the text of an item in a menubar you use SetLabelTop and you pass it a position, not an ID.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!