import tkinter as tk
from tkinter import *
root = tk.Tk()
root.geometry("520x280")
root.resizable(0, 0)
root.title("Test Editor")
def make_menu(w):
global the_menu
the_menu = tk.Menu(w, tearoff=0)
the_menu.add_command(label="Cut")
the_menu.add_command(label="Copy")
the_menu.add_command(label="Paste")
def printInput():
paste = testEntry.get()
# 1.0, "end-1c" put this in the get method
lbl.config(text =paste)
def show_menu(e):
w = e.widget
the_menu.entryconfigure("Cut",
command=lambda: w.event_generate("<<Cut>>"))
the_menu.entryconfigure("Copy",
command=lambda: w.event_generate("<<Copy>>"))
the_menu.entryconfigure("Paste",
command=lambda: w.event_generate("<<Paste>>"))
the_menu.tk.call("tk_popup", the_menu, e.x_root, e.y_root)
printButton = tk.Button(root, text = "Print", command = printInput)
printButton.pack()
make_menu(root)
testEntry = tk.Entry(); testEntry.pack()
testEntry.bind_class("Entry", "<Button-3><ButtonRelease-3>", show_menu)
lbl = tk.Label(root, text = "")
lbl.pack()
root.mainloop()