Can Tk be connect with Copyboard of Linux
Eric Brunel
eric.brunel at pragmadev.com
Mon Feb 18 05:07:32 EST 2002
<posted & mailed>
> Hi, everybody,
Hi,
> Under windows, the copyboard is shared by all the applications. So I can
> copy some messages from different applications, and paste them into a Text
> or Entry widgit based on Tkinter/Tk. But I found the same operation cannot
> work under linux. Under KDE, I can not paste messages from other
> applications into a widget based on Tkinter/Tk. Is it possible to solve
> this problem?
I tried to solve the same problem and I soon realized that talking about
_the_ clipboard with X11 was quite meaningless: there may be as many
clipboards as there are applications. And that seems to be the problem:
several applications use the selection named "CLIPBOARD" to store their
copied data, so the Windows way of doing things should also work on Linux.
But many applications do not use this selection at all, and I couldn't
figure out a way of finding what was the name of the selection they use. So
if you copy things from these, you won't be able to paste them in your
application, but because of them, and not because of Tk or Tkinter...
For example, I've got two editors installed on my Linux box, namely GEdit
and NEdit. GEdit uses the "regular" CLIPBOARD selection, so copy/paste
between GEdit and Tk works. But NEdit doesn't use this selection, so
copy/paste doesn't work...
There is also a way to know if an application uses the CLIPBOARD selection
or not: with every X11 server, a small tool named xclipboard should be
installed. This tool shows the contents of the CLIPBOARD selection. So you
should just run xclipboard, open the application, then select something and
copy it. If it appears in xclipboard, you will be able to paste it back in
your Tk application. If it doesn't, the application doesn't use the regular
CLIPBOARD selection, and you won't be able to get it.
Note however that you can always use the PRIMARY selection that Cameron
talked about, and that there's probably no bindings to do: just copy by
selecting with the left button, and paste by using the middle button. That
should work on any Unix/X11 box. And that seems to be the standard way of
doing things, more than the CLIPBOARD / Ctrl-C / Ctrl-V stuff, which is
more Windows-like.
HTH
- eric -
More information about the Python-list
mailing list