[Pythonmac-SIG] Copying to clipboard (pasteboard)

Schollnick, Benjamin Benjamin.Schollnick at xerox.com
Thu Mar 24 16:19:14 CET 2005


> > import Carbon.Scrap, AppKit, Foundation
> >
> > def clipcopy(arg):
> > 	Carbon.Scrap.ClearCurrentScrap()
> > 	scrap = Carbon.Scrap.GetCurrentScrap()
> > 	scrap.PutScrapFlavor('TEXT', 0, arg)

> That worked!  Thanks a bunch.
> (Now I get to show what kind of a newbie I am.)  Why should I 
> put this into a class?  Is it just better programming practice?  

Well, making this into a class could allow you to simply extend the
functionality....

For example, you could store the changes in a LIST/queue and use the
class to store multiple clipboard entries....

>I suppose the 
> answer may depend on what the script does and how complicated it is.

Exactly...  It depends on how and what you are trying to do....

		- Ben


More information about the Pythonmac-SIG mailing list