Documentation for using the system clipboard ?

Paul Foley see at below.invalid
Thu Mar 6 20:41:51 EST 2003


On Wed, 05 Mar 2003 10:11:09 +0100, Eric Brunel wrote:

>> Could someone point me to the documentation
>> for this feature please.  I would like to use it in code portable to
>> Win32, Linux, and Solaris.

> Since you mention Linux and Solaris, I suppose you just want to
> copy/paste text? I don't know any "standard" way to copy/paste
> graphics with XWindows, so the following code will only work for text:

> ## To copy
> <any Tkinter widget>.clipboard_clear()
> <any Tkinter widget>.clipboard_append("Text to copy", type='STRING')

In fact, it only works for Latin-1 text with no control characters.
If you want it to work for other types, don't use STRING.  E.g., you
can use type PIXMAP if you want graphics.  [I don't know how you do
that from Tk, though.  If you use type PIXMAP, the data should be the
pixmap's resource ID on the X server, not the content]

There's nothing limiting you to transferring plain text on X, any more
than on Windows (less, in fact; the X selection mechanism is *far*
more powerful than the Windows clipboard)

> ## To paste
> text2Paste = <any Tkinter widget>.selection_get(
>                     selection='CLIPBOARD', type='STRING')

Try type='TARGETS'; that should get you a list of target types that
the selection owner is willing to provide.  Pick the one that you
want, and ask for that (it's possible to ask for several types at once
with type MULTIPLE, but I don't know how you'd go about telling it
what types you want, or where to put the results, using the interface
provided by Tkinter)

-- 
Qui beneficium dedit, taceat; narret qui accepit                -- Seneca

(setq reply-to
  (concatenate 'string "Paul Foley " "<mycroft" '(#\@) "actrix.gen.nz>"))




More information about the Python-list mailing list