From where? tkinter? Import? *
Root? =? Tk()
Root.title ('Try the right-click menu of the text box')
Root.resizable(False, false)
root . geometry(" 300 x 100+200+20 ")
Tag (root, Text=' Here is the newly generated text box, try it'). Packaging (side = "top")
Label (root). Packaging (side = "top")
Show? =? String variable ()
Getting started? =? Item (root, textvariable=show,? Width ="30 ")
Entry.pack()
Class? Part:
def? OnPaste (oneself):
Try:
self.text? =? root.clipboard_get()
Except? TCL error:
get through
show.set(str(self.text))
def? OnCopy (itself):
self.text? =? Entry.get()
root . clipboard _ append(self . text)
def? OnCut (ego):
self.onCopy()
Try:
Entry.delete('sel.first ',? sel.last ')
Except? TCL error:
get through
Festival? =? Section ()
Menu? =? Menu (root, tear =0)
Menu.add_command(label= "copy ",? command=section.onCopy)
menu.add_separator()
Menu.add_command(label= "paste ",? command=section.onPaste)
menu.add_separator()
Menu.add_command(label= "cut ",? command=section.onCut)
def? Pop-up menu (event):
menu.post(event.x_root,? event.y_root)
entry . bind(" & lt; Button-3 >,? popupmenu)
root.mainloop()