def FormShow(self, Sender):
self.menu_item=MenuItem(self.PopupMenu1) # PopupMenu1为没有菜单项的弹出菜单
self.menu_item.Caption="aaa" # 菜单标题
self.menu_item.OnClick=self.aa # 点击菜单后执行的代码
self.PopupMenu1.Items.Add(self.menu_item) # 把菜单项加入到弹出菜单中
def aa(*args):
pass
self.PopupMenu1.Items.Delete(0) # 删除第1项菜单
self.PopupMenu2.Items[0].Caption="新名字"
self.PopupMenu2.Items[0].Enabled=False
self.PopupMenu2.Items[0].OnClick=self.新代码