基本语法
AFXMenuPane(owner) #创建菜单面板
AFXMenuTitle(owncr, label,ic=None, popup=None) #创建菜单标题
AFXMenuCommand(owner, p, label, ic=None, tgt=None, sel=0) #创建菜单功能键
AFXMenuCascade(owner, p, label, ic=None, popupNone) #创建子菜单
示例
在用户自定义GUI应用程序中添加菜单,以下为添加自定义菜单的代码。
menu=AFXMenuPane(self)
AFXMenuTitle(self,'复合材料结构分析', None, menu)
AFXMenuCommand(self, menu,'复合材料冲击损伤参数化建模程序',
afxCrcatcPNGIcon(r"iconNimpact_icon.PNG"),
impactForm(self), AFXMode.ID_ACTIVATE)
AFXMenuCommand(self,menu,'六边形蜂窝建模程序',
afxCreatePNGlcon(r"icon\honeycomb_icon.PNG"),
honeycombForm(self),AFXMode.lD_ACTIVATE)
AFXMcnuCommand(self, menu,'过拉伸蜂窝建模程序',
afxCreatePNGIcon(r"iconloverstrething_icon.PNG"),
overstrethingForm(self),AFXMode.ID_ACTIVATE)
subMenu= AFXMenuPane(self)
AFXMenuCascade(self, menu,'子菜单一 ', None,subMenu)
AFXMenuCommand(self, subMenu,'子项目1', None, self,AFXMode.ID_ACTIVATE)
AFXMenuCommand(self, subMenu,'子项目2', None, self,AFXMode.ID_ACTIVATE)
效果是这样的: