[Tutor] About Tkinter

Andy W toodles@yifan.net
Sat, 22 Dec 2001 14:25:42 +0800


> Hi,
> I am a new user of Python. I would like to know how to use the clipboard
> temporary data to use in menu items like copy, paste, etc. I looked around
> the documentation and archives, but all I could find was reference to
> clipboard_append and clipboard_clear.
> Thanks.
> PRJoshi

I did a search on google, and came up with a couple of different answers.
One was to generate a "<Control-v>", which I can't say I like much, but if
it works for you... :)
I also got this from the python-list archive.



Hi there,
>I was wondering how to use the clipboard from Tkinter. I noticed there
>are some methods for clearing and appending to the clipboard, but none
>to retreive something from it... Is there no way at all to retreive
>data from the clipboard using Tkinter? I'm writing a small texteditor
>that has to work cross-platform, so the Tkinter-way would be a lot
>easier than using the windows-clipboard lib. If there's no way to do
>it using Tkinter, though, could you people tell me how to work with
>the clipboard in X? 'Cause I did not find anything about that either
>Thanx a bunch,
>Guido Wesdorp, Holland

It is quite simple atlhough not at all obvious. For example from an
event handler:

  def onRightClick(self, event):
    data =  event.widget.selection_get(selection="CLIPBOARD"))
    print data