Hi:
(Python 2.5 on Suse 9.1 Linux 2.6.x with wxPython 2.8.6.0)
I used pywrap to run the code shown below so I could muck with the running objects.
Then at the pywrap command line I entered:
>>> app.frame.menubar.Disable()
True
At which point the menubar greyed out, as expected.
Ok, now how to get it enabled again? The docs here:
http://www.wxpython.org/docs/api/wx.MenuBar-class.html
Indicate that an id is needed to pass to the Enable() method of a wx.Menubar. Actually the docs are a bit confusing. It says:
"Enable(self, id, enable)," then it says:
Parameters:
enable
(type=bool)
What is the id parameter and why isn't it described?
So I tried this (among other things, none of which worked):
>>> app.frame.menubar.GetId()
-202
>>> app.frame.menubar.Enable(-202, True)
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/_core.py", line 11151, in Enable
return _core_.MenuBar_Enable(*args, **kwargs)
PyAssertionError: C++ assertion "item" failed at ../src/common/menucmn.cpp(1072) in Enable(): attempt to enable an item which doesn't exist
So what is the id required by the enable method, and how to get it? What is the -203? Is that the wx.ID for the menubar? If so, why isn't it accepted by the Enable() method?
Thanks for input.
···
--------------------------------------------------------------------
#!/usr/bin/env python
import wx
class MyFrame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, -1, "Test Frame",
size=(640,480))
self.menubar = wx.MenuBar()
menu = wx.Menu()
self.menubar.Append(menu, "&File")
self.SetMenuBar(self.menubar)
class MyApp(wx.App):
def OnInit(self):
self.frame = MyFrame(None)
self.frame.Show(True)
return True
if __name__ == "__main__":
app = MyApp()
app.MainLoop()
--------------------------------------------------------------------
Good day!
--
_____________________
Christopher R. Carlen
crobc@bogus-remove-me.sbcglobal.net
SuSE 9.1 Linux 2.6.5