Add Menu item by adding command : Menu : Tkinker PYTHON TUTORIALS


PYTHON TUTORIALS » Tkinker » Menu »

 

Add Menu item by adding command


Add Menu item by adding command
from Tkinter import *
def donothing():
    filewin = Toplevel(root)
    button = Button(filewin, text="Do nothing button")
    button.pack()

root = Tk()
menu = Menu(root, tearoff=0)
menu.add_command(label="Cut", command=donothing)
menu.add_command(label="Copy", command=donothing)
menu.add_command(label="Paste", command=donothing)
menu.add_command(label="Delete", command=donothing)
frame = Frame(root, width=100, height=100)
frame.pack()
def popupmenu(event):
    menu.post(event.x_root, event.y_root)
frame.bind("<Button-3>", popupmenu)
root.mainloop()



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Tkinker
» Menu