pyobjc

Why is the PyObjC documentation so bad?

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 muc...

How can I create a status bar item with Cocoa and Python (PyObjC)?

I have created a brand new project in XCode and have the following in my AppDelegate.py file: from Foundation import * from AppKit import * class MyApplicationAppDelegate(NSObject): def applicationDidFinishLaunching_(self, sender): NSLog("Application did finish launching.") statusItem = NSStatusBar.systemStatusBar().stat...

NSWindow launched from statusItem menuItem does not appear as active window

I have a statusItem application written in PyObjC. The statusItem has a menuItem which is supposed to launch a new window when it is clicked: # Create statusItem statusItem = NSStatusBar.systemStatusBar().statusItemWithLength_(NSVariableStatusItemLength) statusItem.setHighlightMode_(TRUE) statusItem.setEnabled_(TRUE) statusItem.retain()...

What is the best way to sample/profile a PyObjC application?

Sampling with Activity Monitor/Instruments/Shark will show stack traces full of C functions for the Python interpreter. I would be helpful to see the corresponding Python symbol names. Is there some DTrace magic that can do that? Python's cProfile module can be useful for profiling individual subtrees of Python calls, but not so much for...

Cocoa client/server application

Is there a way in Cocoa that is currently considered best practice for creating a multi-tier or client server application? I'm an experienced web developer and I really love Python. I'm new to Cocoa though. The application I'm toying with writing is a patient management system for a large hospital. The system is expected to store huge a...

PyObjc vs RubyCocoa for Mac development: Which is more mature?

I've been wanting to have a play with either Ruby or Python while at the same time I've been wanting to do a bit of Cocoa programming. So I thought the best way to achieve both these goals is to develop something using either a Ruby or Python to Objective-C bridge (PyObjc or RubyCocoa). I know that ideally to get the best learning exp...

Display logging output in Cocoa

What is the best way to display constantly updated logging output using Cocoa Components? The output is line-based and generated by the application. Appending lines should be fast, and the view should automatically scroll to the bottom. All in all, it should work and look like basic standard out in a terminal. My code is written in Pyth...

Handle OSX Dock Drag N Drop

I looked high and low for information on how to handle drag n drop to the dock in OSX. The drag n drop documentation (http://developer.apple.com/documentation/Cocoa/Conceptual/DragandDrop/DragandDrop.html#//apple_ref/doc/uid/10000069) I found all deal with dragging from view to view. If anyone can point me to some code samples, that woul...

NSThread or pythons' threading module in pyobjc?

I need to do some network bound calls (e.g., fetch a website) and I don't want it to block the UI. Should I be using NSThread's or python's threading module if I am working in pyobjc? I can't find any information on how to choose one over the other. Note, I don't really care about Python's GIL since my tasks are not CPU bound at all. ...

PyObjC + Python 3.0 Questions

By default, a Cocoa-Python application uses the default Python runtime which is version 2.5. How can I configure my Xcode project so that it would use the newer Python 3.0 runtime? I tried replacing the Python.framework included in the project with the newer version but it did not work. And another thing, are PyObjc modules compatible w...

Ugly looking text when drawing NSAttributedString in CGContext

Hello, 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 CGContextSe...

Why is my PyObjc Cocoa view class forgetting its fields?

I was trying to hack up a tool to visualize shaders for my game and I figured I would try using python and cocoa. I have ran into a brick wall of sorts though. Maybe its my somewhat poor understand of objective c but I can not seem to get this code for a view I was trying to write working: from objc import YES, NO, IBAction, IBOutlet fr...

How to stop an NSInvocationOperation?

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 probl...

Running python code from standard Cocoa application

I have an XCode project built as a Cocoa single document application (it's not a Python-Cocoa application, that is not what I want). All the documentation I found assumes I want to create a Cocoa application with code written in Python and this is not the case - I want a standard Cocoa application that calls a method out of a Python cla...

Is it possible to call a Python module from ObjC?

Using PyObjC, is it possible to import a Python module, call a function and get the result as (say) a NSString? For example, doing the equivalent of the following Python code: import mymodule result = mymodule.mymethod() ..in pseudo-ObjC: PyModule *mypymod = [PyImport module:@"mymodule"]; NSString *result = [[mypymod getattr:"mymeth...

How do I choose which Python installation to run in a PyObjC program?

I use Python 2.6 more than I use Leopard's default python installation, so I have it set as my main Python installation. But I'd rather use the default Python for a PyObjC program I'm working on. Is there any way to specify to only use it instead of Python 2.6? ...

How do I represent a void pointer in a PyObjC selector?

I'm wanting to use an NSOpenPanel for an application I'm designing. Here's what I have so far: @objc.IBAction def ShowOpenPanel_(self, sender): self.panel = NSOpenPanel.openPanel() self.panel.setCanChooseFiles_(False) self.panel.setCanChooseDirectories_(True) NSLog(u'Starting OpenPanel') self.panel.beginForDirectory...

BWSplitView and PyObjc

I'm trying to use Brandon Walkin's BWSplitView from BWToolkit in a Cocoa PyObjc project. When I run the project I get the following error message: NSInvalidUnarchiveOperationException - *** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (BWSplitView) Does this mean his toolkit is incompatible with a PyObc proj...

Unicode problems in PyObjC

I am trying to figure out PyObjC on Mac OS X, and I have written a simple program to print out the names in my Address Book. However, I am having some trouble with the encoding of the output. #! /usr/bin/env python # -*- coding: UTF-8 -*- from AddressBook import * ab = ABAddressBook.sharedAddressBook() people = ab.people() for person...

Implimenting NSText delegate methods in PyObjc and Cocoa

In the project that I'm building, I'd like to have a method called when I paste some text into a specific text field. I can't seem to get this to work, but here's what I've tried I implimented a custom class (based on NSObject) to be a delegate for my textfield, then gave it the method: textDidChange: class textFieldDelegate(NSObject):...