The example below illustrates how to add a simple menu to a Tk toplevel window.

Running the code above gives the following window:

The example below demonstrates how to add a simple pop-up menu to a text window. The hard part is determining the mouse coordinates in order to ensure that the menu appears where the mouse is right-clicked. Note that the keyboard shortcuts for copying and pasting (<Ctrl-C> and <Ctrl-V>) are mapped automatically for a Tk text widget.