Python GUI编程(Tkinter)17、Menu鼠标右键菜单

import tkinter

win = tkinter.Tk()
win.title("sunck")
win.geometry("400x400+200+20")

#菜单条
menubar = tkinter.Menu(win)

#菜单
menu = tkinter.Menu(menubar, tearoff=False)
for item in ["Python", "C", "C++", "OC", "Swift", "C#", "shell", "Java", "JS", "PHP", "汇编", "NodeJS", "退出"]:
menu.add_command(label=item)

menubar.add_cascade(label="语言", menu=menu)

def showMenu(event):
menubar.post(event.x_root, event.y_root)
win.bind("<Button-3>", showMenu)


win.mainloop()
posted @ 2020-05-19 16:11  i勤能补拙  阅读(1114)  评论(0编辑  收藏  举报