I would like to make menu items (in the menu bar, and not in the pop-up window of the right mouse button) that can cut / copy / paste any text.
Equivalent keyboard commands already work if I havenβt done anything to enable them. For example, I can enter text in an input field, cut it out with Control-X and paste it back (or in another place) with Control-C.
Messages on a topic that I saw come down to cut / copy / paste for individual widgets, but that already works. How to make menu items activate them?
Thank.
EDIT: To be clear, the problems are:
- how to make menu items for cut / copy action on any text selected in any widget
- how to have a paste menu item, paste text wherever the text cursor
Again, the key commands for this (Control-x, Control-c, Control-v) already work without my having to do anything. I know how to make a menu; the question is which command should I attach to the menu items in order to have the desired effect.
EDIT 2: Ok, I have a way that works. Since the key commands are already working, we can simply generate them. In my case, everything is a notebook called noteBook, so
lambda: self.noteBook.event_generate('<Control-x>')
cuts as desired. For instance:
editmenu.add_command(label="Cut", accelerator="Ctrl+X", command=lambda: self.noteBook.event_generate('<Control-x>'))
When using: https://github.com/lnmaurer/qubit-control-interface/commit/c08c10a7fbc4a637c1e08358fb9a8593dfdf116e
However, there may be a cleaner way to do this; answer if you know it.