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

AndroidAmelia 2020-05-19

import tkinterwin = 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()

相关推荐