Hi there

I'm writing add-in code for EA 4.50.744 (Unicode) in Python.
I want to control the menu state (selectable or not) by EA_GetMenuState, but I can't.
# I attach my code at the end of this mail
In this code, I define 1 parent menu "AAA" and 2 child menus "BBB", "CCC". I expect that menu "AAA" and "BBB" are selectable, "CCC" is not.
But, all the menus are selectable. Why?

Is there any example that control menu state in Python?
My envirronment
OS Windows XP SP1
Python 2.4.1
wxPython wx-2.5.5-msw-unicode
*****
import sys
from win32com.server.util import wrap, unwrap
import win32com.client
import wx
# For defaultencoding
if hasattr(sys,"setdefaultencoding"):
sys.setdefaultencoding("shift_jis")
# For Late Bound
from win32com.client import dynamic
# For debug
debugging = 0
if debugging:
from win32com.server.dispatcher import DefaultDebugDispatcher
useDispatcher = DefaultDebugDispatcher
else:
useDispatcher = None
#
class TestPlugIn(wx.App):
#
_public_methods_ = [ 'EA_MenuClick',
'EA_GetMenuItems',
'EA_GetMenuState',
]
#
_reg_progid_ = "PythonUtil.TestPlugIn"
#
#
# >>> import pythoncom
# >>> print pythoncom.CreateGuid()
#
_reg_clsid_ = "{3DBD5A66-CCBC-4545-85FE-784F99A4CE94}"
# Menu items
def EA_GetMenuItems(self, Repository, MenuLocation, MenuName):
if MenuName == "":
menu = [
u'-&AAA', ]
elif MenuName == u'-&AAA':
menu = [
u'&BBB',
u'&CCC',
]
return menu
# Menu state control
def EA_GetMenuState(self, Repository, MenuLocation, MenuName,
ItemName, IsEnabled, IsChecked):
## print "EA_GetMenuState"
if MenuLocation == "TreeView":
IsEnabled = False
elif MenuLocation == "Diagram":
IsEnabled = False
elif MenuLocation == "MainMenu":
if MenuName == u'-&AAA':
IsEnabled = True
if ItemName == u'&BBB':
IsEnabled = True
else:
IsEnabled = False
print MenuName, ItemName, IsEnabled
def EA_MenuClick(self, Repository, MenuLocation, MenuName, ItemName):
print "No choice"
def main():
print "TestPlugin ver", version
app = TestPlugIn(0)
app.MainLoop()
if __name__ == '__main__':
if len(sys.argv) < 2:
main()
else:
import win32com.server.register
if sys.argv[1] == "--register":
print "regist COM server"
print "TestPlugin ver", version
win32com.server.register.UseCommandLine(TestPlugIn,
debug=debugging)
elif sys.argv[1] == "--unregister":
print "Unregist COM server"
print "TestPlugin ver", version
win32com.server.register.UseCommandLine(TestPlugIn)
else:
print "Usage: testplugin.py [--register|--unregister]"
*****