[Tutor] clipboard questions

Alan Gauld alan.gauld at btinternet.com
Mon Jan 26 11:13:15 CET 2009


"Che M" <pine508 at hotmail.com> wrote

> I'm curious about how to interact with the contents of the clipboard
> effectively and have a couple of questions...
>
> 1) Is there one cross-platform way to read the clipboard,

In a generic sense no. But if the cut n paste is within a single
application then yes, you can use a cross platform GUI framework.
That will work across OS versions. Where it gets messy is if you
want to paste from the generic OS clipboard into your application
and different frameworks vary in how well they handle that.

> 2) I would like to be able to copy formatting (bold, italics, 
> bullets,
> hyperlinks, etc.) into the clipboard and then have Python have 
> access
> to the text content and its formatting

Thats even more tricky because not all clipboards will capture
formatting codes in their original form. Some require special
commands/events. It may also depend on the application that
you are copying from. For example consider a MacOS web
browser. Do you want to copy the underlying HTML formatting
tags? Or the display PDF codes which are used by the Aqua
graphics system used by the browser to actually display the
output?

In other words your display mechanism will need to be able
to display whatever the clipboard passes. And your applucatin
will need to be able to extract the data from it (eg parse PDF
or RTF etc)

Cut n paste between apps is non trivial even on a single OS
and within a single framework. But if you have mixed environments
it can get really messy in my experience! If it's all within a single
framework then its not so bad.

Alan G 




More information about the Tutor mailing list