![Menu-右键弹出菜单 Menu-右键弹出菜单](https://image.shishitao.com:8440/aHR0cHM6Ly9ia3FzaW1nLmlrYWZhbi5jb20vdXBsb2FkL2NoYXRncHQtcy5wbmc%2FIQ%3D%3D.png?!?w=700&webp=1)
#右键弹出菜单
from tkinter import * root=Tk() def callback():
print('我被调用了') menubar =Menu(root)
menubar.add_command(label='编辑',command=callback)
menubar.add_command(label='撤销',command=callback) frame= Frame(root,width=300,height=300)
frame.pack() def popup(event): menubar.post(event.x_root,event.y_root) frame.bind('<Button-3>',popup) mainloop()