pyobjc

Converting CGImage to python image (pil/opencv)

*爱你&永不变心* 提交于 2019-12-25 02:51:20
问题 I want to do some pattern recognition on my screen and will use the Quartz/PyObjc libraries to get the screenshots. I get the screenshot as a CGImage. I want to search for a pattern in it using the openCV library, but can't seem to find how to convert the data to be readable by opencv. So what I want to do is this: #get screenshot and reference pattern img = getScreenshot() # returns CGImage instance, custom function, using Quartz reference = cv2.imread('ref/reference_start.png') #get the

Installing Pyglet in mac

对着背影说爱祢 提交于 2019-12-25 02:38:33
问题 I have followed this link in order to install pyglet in mac, because it is the only resource I have found that solves the "wrong architecture" problem. However, when I execute the last commmand pip install pyobjc==2.2 , it gives me the following error: AttributeError: 'module' object has no attribute '_install_lib' ---------------------------------------- Cleaning up... Command /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -c "import setuptools,

Python capture Keystrokes values in text file on OS X

跟風遠走 提交于 2019-12-21 02:36:09
问题 I am trying to monitor keystrokes on my Macbook on order to build a statistics analyzer. But how can I isolate the chars from "event" which is more something like : NSEvent: type=KeyDown loc=(850,248) time=66551.8 flags=0x100 win=0x0 winNum=0 ctxt=0x0 chars="l" unmodchars="l" repeat=0 keyCode=37 So do anyone know how to, based on the script posted below, fulfill a .txt doc with the value of chars (from NSEvent) ? I need a text file with a the pressed keys in order to run my other script on it

Writing metadata to a pdf using pyobjc

放肆的年华 提交于 2019-12-21 01:58:33
问题 I'm trying to write metadata to a pdf file using the following python code: from Foundation import * from Quartz import * url = NSURL.fileURLWithPath_("test.pdf") pdfdoc = PDFDocument.alloc().initWithURL_(url) assert pdfdoc, "failed to create document" print "reading pdf file" attrs = {} attrs[PDFDocumentTitleAttribute] = "THIS IS THE TITLE" attrs[PDFDocumentAuthorAttribute] = "A. Author and B. Author" PDFDocumentTitleAttribute = "test" pdfdoc.setDocumentAttributes_(attrs) pdfdoc.writeToFile_

How to Listen For an Application Launch Event in Mac OS X?

本小妞迷上赌 提交于 2019-12-18 18:04:23
问题 I wrote an AppleScript to mount a SparseBundle image and I want it to be executed exactly when Time Machine launches. Right now, I periodically check if Time Machine is running with AppleScript using on idle statement: on idle .... return <interval> end idle which isn't a robust way. In my opinion adding an event trigger for Application Launch event would be a better approach. Could you please help? An Objective-C or Python sample code (I'd prefer Python ) is more than welcome. 回答1: What you

wxPython Mac OS X Fullscreen work around error

冷暖自知 提交于 2019-12-13 22:12:45
问题 I was trying to get fullscreen support for a wxPython app using the code in the answer from this stackoverflow question wxPython MacOS X Lion full screen mode My Error Traceback (most recent call last): File "test_mac_fullscreen.py", line 36, in <module> frame = Frame() File "test_mac_fullscreen.py", line 29, in __init__ SetFullScreenCapable(self) File "test_mac_fullscreen.py", line 16, in SetFullScreenCapable window = frameobj.window() AttributeError: 'NSHIObject' object has no attribute

Apply a Quartz filter while saving PDF under Mac OS X 10.6.3

本小妞迷上赌 提交于 2019-12-13 17:06:46
问题 Using Mac OS X API, I'm trying to save a PDF file with a Quartz filter applied, just like it is possible from the "Save As" dialog in the Preview application. So far I've written the following code (using Python and pyObjC, but it isn't important for me): -- filter-pdf.py: begin from Foundation import * from Quartz import * import objc page_rect = CGRectMake (0, 0, 612, 792) fdict = NSDictionary.dictionaryWithContentsOfFile_("/System/Library/Filters/Blue \ Tone.qfilter") in_pdf =

Is PyObjC pre-installed on OSX SL?

坚强是说给别人听的谎言 提交于 2019-12-13 02:58:50
问题 I'm going to sell a program that uses that framework in Mac App Store. I want to make sure it will be approved by Apple. 回答1: Yes. $ /usr/bin/python2.6 Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) [GCC 4.2.1 (Apple Inc. build 5646)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import objc >>> objc.__file__ '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC/objc/__init__.pyc' 来源: https://stackoverflow.com/questions

How can I capture iSight frames with Python in Snow Leopard?

空扰寡人 提交于 2019-12-12 08:09:11
问题 I have the following PyObjC script: from Foundation import NSObject import QTKit error = None capture_session = QTKit.QTCaptureSession.alloc().init() print 'capture_session', capture_session device = QTKit.QTCaptureDevice.defaultInputDeviceWithMediaType_(QTKit.QTMediaTypeVideo) print 'device', device, type(device) success = device.open_(error) print 'device open success', success, error if not success: raise Exception(error) capture_device_input = QTKit.QTCaptureDeviceInput.alloc()

Problem With openPanelDidEnd in PyObjC in 10.6

佐手、 提交于 2019-12-12 05:29:54
问题 The following code which worked fine under OS X 10.5 now fails on 10.6: @IBAction def addButton_(self, sender): panel = NSOpenPanel.openPanel() panel.setCanChooseDirectories_(YES) panel.setAllowsMultipleSelection_(YES) try: panel.beginSheetForDirectory_file_modalForWindow_modalDelegate_didEndSelector_contextInfo_(self.directory, None, NSApp().mainWindow(), self, 'openPanelDidEnd:panel:returnCode:contextInfo:', None) except: pass @AppHelper.endSheetMethod def openPanelDidEnd_panel_returnCode