[Pythonmac-SIG] Copying to clipboard (pasteboard)
Bob Ippolito
bob at redivi.com
Wed Mar 23 00:53:15 CET 2005
On Mar 22, 2005, at 6:29 PM, Doug Schwarz wrote:
> import Carbon.Scrap, AppKit, Foundation
>
> def clipcopy1(arg):
> board = AppKit.NSPasteboard.generalPasteboard()
> board.declareTypes_owner_([AppKit.NSStringPboardType], None)
> newStr = Foundation.NSString.stringWithString_(arg)
> newData =
> newStr.nsstring().dataUsingEncoding_(Foundation.NSASCIIStringEncoding)
> board.setData_forType_(newData, AppKit.NSStringPboardType)
This should probably be written as:
from AppKit import *
from Foundation import *
def clipcopy1(arg):
# assume that arg is ASCII
board = NSPasteboard.generalPasteboard()
board.declareTypes_owner_([NSStringPboardType], None)
board.setString_forType_(unicode(arg), NSStringPboardType)
-bob
More information about the Pythonmac-SIG
mailing list