Le Mon, 26 Jan 2009 02:23:05 -0500,
Che M <pine...@hotmail.com> a écrit :

> 
> 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, or does one
> have to have a different way to do it for Win, Mac, and Linux?  (I have
> seen some ways with the win32clipboard module, and so thought maybe one
> has to do a similar thing for each platform).
> 
> 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 in such a way that it could be 
> pasted somewhere within a Python app with formatting preserved.  How 
> can that be done?

The way content text will actually be rendered is specified by additional 
information. There are tons of dedicated languages for that, usually "markup" 
languages. Some are plain text (and usually open), some binary (and usually 
proprietary).
When you copy a snippet of text from formatted document, depending on the kind 
of format, on the source application, and even on the copying program, you may 
or may not copy the formatting together with the content. This will work e.g. 
for plain text formatting copied from a plain text editor, such as a wikitext 
copied from its edition frame.
Now, this will not give you a styled text. The text will show properly rendered 
only if the target application (say, your own program) is able to parse, 
interpret and process the formatting information supplied together with the 
content. Meaning it must 'know' the markup language. Or, you must use a 
translation tool from the source markup to another that is known by the target 
application.

Also note that most markup languages such as the various wikilang dialects & 
the various versions of x/html do not (or rather should not) actually describe 
the *aspect* of the rendered text, instead they specify the kind, class, 
meaning of portions of text, such as "this is title" or "this is an important 
note", "this a book reference". Then, at rendering time, the engine will look 
for a description of each of these text style classes, which is most often 
specified in separate style sheets, e.g. CSS files. There are several relevant 
reasons for that.

Denis

> Thanks for any suggestions or thoughts.
> Che

------
la vida e estranya
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to