April 2018
Beginner
340 pages
7h 54m
English
Once again we will need to add some code to our __init__ method. Since there will only be one Menu needed for our context menu we can just define this directly instead of making another function. Type this code underneath the previous menu code:
self.right_click_menu = tk.Menu(self, bg="lightgrey", fg="black", tearoff=0)self.right_click_menu.add_command(label='Cut', command=self.edit_cut)self.right_click_menu.add_command(label='Copy', command=self.edit_copy)self.right_click_menu.add_command(label='Paste', command=self.edit_paste)
Another Menu widget is created using the same arguments as all of our cascades. We then add three commands to it—cut, copy, and paste. These will still do nothing at the moment, ...