[Tutor] Cut, Copy, and Paste in Tkinter (original) (raw)

Marv Boyes marvboyes at att.net
Thu Jul 8 05:06:30 CEST 2004


Hello, all. I'm trying to get a Paste function to work in a little Tkinter notepad-type application I'm working on (I hate Linux's Knotes and want to replace it on my machine). I've been using Martin Ultima's PyWord for inspiration and guidance, and I've had success adapting the Cut and Copy routines he used, but for some reason I can't manage a Paste.

Here's what I have to define cut and copy (where "text" is the name of my text widget); these are working for me:

def cut_text(text): try: text._clipboard = text.get("sel.first", "sel,last") text.delete("sel.first", "sel.last") except: pass

def copy_text(text): try: text = text.get("sel.first", "sel.last") except: pass

[I don't know whether or not it's pertinent, but text cut and/or copied from my application successfully pastes into other applications.]

I'm not getting anywhere with paste, no matter what I try. I've tried more-or-less copying (in spirit, adapted for my purpose) the PyWord paste routine, but that doesn't even work. I've made sure that my keybindings are correct. Can anyone point me in the right direction?

Many thanks in advance,

Marv

Help in the research to fight devastating diseases like Huntington's, Parkinson's, and Alzheimer's-- donate your computer's leisure time to Folding at Home. http://www.stanford.edu/group/pandegroup/folding/



More information about the Tutor mailing list