Mega Code Archive

 
Categories / Python Tutorial / Tkinker
 

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_command( label = "Cut", command = self.Cut )         contextMenu.add_command( label = "Copy", command = self.Copy )         contextMenu.add_command( label = "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()