代码演示
import wx
class MyApp(wx.App):
def OnInit(self):
frame = wx.Frame(parent=None, title="右键菜单")
panel = wx.Panel(frame, -1)
self.panel = panel
# 创建一个菜单
menu = wx.Menu()
copy = menu.Append(-1, "copy")
paste = menu.Append(-1, "paste")
self.menu = menu
self.Bind(wx.EVT_RIGHT_DOWN, self.right_click)
frame.Show()
return True
def right_click(self, event):
pos = (event.x, event.y)
self.panel.PopupMenu(self.menu, pos)
app = MyApp()
app.MainLoop()