Context Menus : Menu : Tkinker PYTHON TUTORIALS


PYTHON TUTORIALS » Tkinker » Menu »

 

Context Menus


Context Menus
from Tkinter import *

class ContextMenuTest :

    def Cut(self:
        print "Cut"

    def Copy(self:
        print "Copy"

    def Paste(self:
        print "Paste"

    def OnContext(self, args:
        contextMenu = Menu(None, tearoff=0)
        contextMenu.add_commandlabel = "Cut", command = self.Cut )
        contextMenu.add_commandlabel = "Copy", command = self.Copy )
        contextMenu.add_commandlabel = "Paste", command = self.Paste )
        contextMenu.tk_popup(args.x_root, args.y_root, entry="")

    def __init__(self:
        self.root = Tk()
        self.root.geometry("300x500")
        self.root.bind("<Button-3>", self.OnContext )
        self.root.mainloop()

cmt = ContextMenuTest()



Leave a Comment / Note


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


PYTHON TUTORIALS

 Navioo Tkinker
» Menu