fredag 23 april 2010

Send text to Mac ClipBoard from python (like pbcopy)

def sendToClipBoard(string):
    from AppKit import NSPasteboard,NSObject,NSStringPboardType
    pasteboard = NSPasteboard.generalPasteboard()
    emptyOwner = NSObject.alloc().init()
    pasteboard.declareTypes_owner_([NSStringPboardType], emptyOwner)
    pasteboard.setString_forType_(string, NSStringPboardType)

if __name__ == "__main__":
    import sys
    sendToClipBoard(sys.stdin.read())

Idea from this marvellous post about writing a SIMBL plugin in Python.

About the building the TabDump plugin:
When I built the SIMBL plugin, I had to compile it with
/usr/bin/python setup.py py2app
and I had to set MaxBundleVersion='6531' in setup.py

Anothere way is to build it with
/usr/bin/python setup.py py2app -s --site-packages
It doesn't copy in 16 MB python stuff into the bundle.

For some reason /opt/local/bin/python doesn't work, because
then py2app makes only a i368 binary, not a x86_64 binary.  Weird.

1 kommentar:

  1. It was subsequently a really “ hoppy” 100th Afternoon associated with Kindergarten! As soon as is usually the 100th day time regarding The school? Does one commemorate at a exclusive approach? Why not have your opinions during the comments� So i am previously planning following that year's party! You will also uncover even more fantastic tips on your 100th Working day celebrations during these kind of websites. https://imgur.com/a/WIDY7yi https://imgur.com/a/LeTeHFR https://imgur.com/a/OsetDBY https://imgur.com/a/wFfWkea https://imgur.com/a/iJKt5MG https://imgur.com/a/yUYqApx https://imgur.com/a/EzK1iOw

    SvaraRadera