[Pythonmac-SIG] Re: GetScrap -- use of?
Mike Byrne
byrne@acm.org
Mon, 22 Feb 1999 14:43:21 -0500
On 99.02.22, Joseph J. Strout <joe@strout.net> wrote:
> Anybody (Jack?) know how to use Scrap.GetScrap? The docstring on it
> sez:
>
> (Handle hDest, ResType theType) -> (long _rv, long offset)
>
> According to Inside Mac, I should be able to pass a null handle for
> the first parameter if I just want to see whether a certain type is
> on the clipboard. But neither of these works:
>
> >>> Scrap.GetScrap(None, 'TEXT')
> TypeError: Resource required
>
> >>> Scrap.GetScrap(0,'TEXT')
> TypeError: Resource required
>
> I also can't figure out how to get the data;
I ran into this, too. You have to make a "dummy" resource, and then you
access the results with the "data" field. Here's the function I use to
get the text on the clipboard:
import Res
import Scrap
def scrapString():
TheScrap = Res.Resource("")
Scrap.GetScrap(TheScrap, 'TEXT')
return TheScrap.data
There's probably a better way to do this, but this has worked for me so
far.
-Mike
===========================================================
Mike Byrne, Ph.D. byrne@acm.org +1 412-268-3498
Postdoctoral Research Associate in Cognitive Psychology/HCI
Psychology Department, Carnegie Mellon University
Pittsburgh, PA 15213-3890
http://act.psy.cmu.edu/ACT/people/byrne/index.html