pyobjc

How do you listen to notifications from iTunes on a Mac (Using the NSDistributedNotificationCenter)

和自甴很熟 提交于 2019-11-28 11:29:44
Looking for help/tutorials/sample code of using python to listen to distributed notifications from applications on a mac. I know the py-objc lib is the bridge between python and mac/cocoa classes, and the Foundation library can be used to add observers, but looking for examples or tutorials on how to use this to monitor iTunes. If anyone comes by to this question, i figured out how to listen, the code below works. However accessing attributes do not seem to work like standard python attribute access. Update: you do not access attributes as you would in python i.e (.x), the code has been

py2app is not copying the Python.framework to the new app while using virutalenv

三世轮回 提交于 2019-11-28 11:17:57
environment: MacOS X 10.7.2, system installed python 2.7.1, virtualenv 1.7.2, pyobjc 2.3, py2app 0.6.4+ I have a newly created virtualenv with pyobc 2.3 and py2app installed. When I run python setup.py py2app to create an app (for example in py2app/examples/simple) everything seems to compile and it does produce a double clickable app, but after clicking on that app I get the following error: A Python runtime not could be located. You may need to install a framework build of Python, or edit the PyRuntimeLocations array in this application's Info.plist file. However, if i follow the same

Getting pyobjc object from integer id

家住魔仙堡 提交于 2019-11-28 10:15:01
问题 Is there a way to get a PyObjC proxy object for an Objective-C object, given only its id as an integer? Can it be done without an extension module? In my case, I'm trying to get a Cocoa proxy object from the return value of wx.Frame.GetHandle (using wxMac with Cocoa). 回答1: The one solution I did find relies on ctypes to create an objc_object object from the id : import ctypes, objc _objc = ctypes.PyDLL(objc._objc.__file__) # PyObject *PyObjCObject_New(id objc_object, int flags, int retain)

PyObjC and returning 'out' parameters (i.e. NSError **)

守給你的承諾、 提交于 2019-11-28 09:18:46
问题 I'm implementing an ObjC protocol as a mix-in for a PyObjC class. This protocol defines an 'out' parameter. I am unable to find any good documentation on how a Python class which implements an ObjC protocol defining this is to behave. I've found this mailing list thread but the suggestion in there does not work. They say to return a Python list with the method's return value as the first item and the out parameter as the second. I've tried this and all I get is an exception when calling from

ImportError: No module named Foundation

让人想犯罪 __ 提交于 2019-11-28 06:51:41
I am trying to follow the instructions for the accepted answer to "PyObjC development with Xcode 3.2". I will repost them here since I don't have enough rep to comment on the actual question: Here's what I have done to get PyObjC working in Snow Leopard: Using the Finder, I went to Go > Connect to Server... and connected to http://svn.red-bean.com/pyobjc/trunk/pyobjc/pyobjc-xcode/ as a guest. I then made a folder called Xcode on my local system at ~Library/Application Support/Developer/Shared/Xcode/ . (You may already have this folder, but I hadn't customized anything for myself yet). I copied

PyObjC on Xcode 4

筅森魡賤 提交于 2019-11-28 06:32:53
Xcode 3 had templates for building Cocoa subclasses in Python. I've recently upgraded to Xcode 4 but I cannot find out how I can use other languages besides the C family (C, C++, Obj-C) in Xcode 4. Does anyone know? The Python-Cocoa class templates you're looking for are part of PyObjC, but Apple stopped including them in the install around the end of Leopard (I think), because they got out of sync with Xcode. You can download the latest versions yourself from the PyObjC repository . According to this recent guide I found, they should go in ~/Library/Developer/Xcode/Templates/. Beware, however

How to stop an NSInvocationOperation?

一曲冷凌霜 提交于 2019-11-27 16:26:36
问题 I have an NSInvocationOperation that would download and parse a series of NSXMLDocuments in the background to my UI responsive. My attempt at stopping the Invocation operation is to call my NSOperationQueue's cancellAllOperations. But it seems that this won't stop the invocation's execution. Any ideas on how would I go about this problem? 回答1: It's up to the implementation of your NSOperation object to actually stop what it's doing, clean up, and exit when it gets notified that it's been

Ugly looking text when drawing NSAttributedString in CGContext

北城余情 提交于 2019-11-27 16:20:28
问题 I want to display strings inside CoreAnimation layers, but unfortunately CATextLayer is not enough, mostly because it's difficult to use when using constraints and you want to wrap the text. I am using NSLayoutManager, using the following code (PyObjC): NSGraphicsContext.saveGraphicsState() # THIS SOLVES THIS ISSUE CGContextSetShouldSmoothFonts(ctx, False) graphics = NSGraphicsContext.graphicsContextWithGraphicsPort_flipped_(ctx, True) NSGraphicsContext.setCurrentContext_(graphics) height =

Why is the PyObjC documentation so bad? [closed]

核能气质少年 提交于 2019-11-27 15:53:40
问题 For example, http://developer.apple.com/cocoa/pyobjc.html is still for OS X 10.4 Tiger, not 10.5 Leopard.. And that's the official Apple documentation for it.. The official PyObjC page is equally bad, http://pyobjc.sourceforge.net/ It's so bad it's baffling.. I'm considering learning Ruby primarily because the RubyCocoa stuff is so much better documented, and there's lots of decent tutorials (http://www.rubycocoa.com/ for example), and because of the Shoes GUI toolkit.. Even this badly-auto

How to put a tkinter window on top of the others?

梦想与她 提交于 2019-11-27 12:47:26
I'm using Python 2 with Tkinter and PyObjC , and then I'm using py2app . The program is working fine, but the window starts as hidden whenever I open the program, so it doesn't appear until I click on the icon on the dock to bring it up. Is there any way to control this, make the window to be on top of other windows that were open when the application is starting? Just to clarify, it doesn't have to be on the top for the whole time the application is running. I just need it to be on top of other windows when it starts. vdbuilder If I take the code you give and add the first and last line you