pyobjc

Calculating first and last days of current week

爱⌒轻易说出口 提交于 2019-12-07 15:11:33
问题 Reference to pre-answered question at: Getting first and last days of current week There are two answers in the above link. One of them is theoretical and the other is in a language called as PyObjC (Python-Objective C bridge language), and a quick google search confirms that PyObjC does not work with iPhone SDK. So regarding the question, how is it possible to get the PyObjC code translated to be compatible with iPhone SDK. Target: Supposing today (Tue.) is 19th, and Sun. was 17th (start of

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

只愿长相守 提交于 2019-12-07 05:04:29
问题 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 getting a picture of what's going on with the whole application in response to user events. 回答1: The answer is "dtrace", but it won't work on sufficiently

PyObjC + Xcode 3.2 + Non-Apple Python

↘锁芯ラ 提交于 2019-12-06 09:09:33
问题 I want to get started trying to develop a few simple applications with PyObjC. I installed PyObjC and the Xcode templates. I know that PyObjC itself works, since I've run this script successfully. When I tried to create a project from the Cocoa-Python Application template and ran it, I got this error: Traceback (most recent call last): File "main.py", line 10, in import objc File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PyObjC/objc/__init__.py",

Calculating first and last days of current week

こ雲淡風輕ζ 提交于 2019-12-05 19:50:23
Reference to pre-answered question at: Getting first and last days of current week There are two answers in the above link. One of them is theoretical and the other is in a language called as PyObjC (Python-Objective C bridge language), and a quick google search confirms that PyObjC does not work with iPhone SDK. So regarding the question, how is it possible to get the PyObjC code translated to be compatible with iPhone SDK. Target: Supposing today (Tue.) is 19th, and Sun. was 17th (start of week) and Sat. 23rd is end of week. I want to get a string like 19/01 - 23/01 [i.e. The start of week

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

时光总嘲笑我的痴心妄想 提交于 2019-12-05 07:13:56
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 getting a picture of what's going on with the whole application in response to user events. wnoise The answer is "dtrace", but it won't work on sufficiently old macs. http://tech.marshallfamily.com.au/archives/python-dtrace-on-os-x-leopard-part-1/ http://tech

PyObjC + Xcode 3.2 + Non-Apple Python

回眸只為那壹抹淺笑 提交于 2019-12-04 17:09:34
I want to get started trying to develop a few simple applications with PyObjC. I installed PyObjC and the Xcode templates. I know that PyObjC itself works, since I've run this script successfully. When I tried to create a project from the Cocoa-Python Application template and ran it, I got this error: Traceback (most recent call last): File "main.py", line 10, in import objc File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PyObjC/objc/__init__.py", line 25, in from _convenience import * File "/opt/local/Library/Frameworks/Python.framework/Versions/2

PyObjC + Python 3.0 Questions

情到浓时终转凉″ 提交于 2019-12-04 03:14:25
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 with the new version of Python? PyObjC does not yet work with Python 3.0. According to Ronald Oussoren, a (the?) PyObjC developer, Python 3.0 support is possible, but not yet implemented: Support for Python 3.x is on my todo list but is non-trivial to achieve.

Is it possible to call a Python module from ObjC?

若如初见. 提交于 2019-12-03 12:51:52
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:"mymethod"] call:@"mymethod"]; dbr As mentioned in Alex Martelli's answer (although the link in the mailing-list message was broken, it should be https://docs.python.org/extending/embedding.html#pure-embedding ).. The C way of calling.. print urllib.urlopen("http://google

PyObjc and Cocoa on Snow Leopard

情到浓时终转凉″ 提交于 2019-12-03 09:18:57
问题 I am about to start my A-Level Computing project (High School Level) which will hopefully be a point-of-sale application for Mac OS. Unfortunately, Objective-C is a little out of my league at the moment and should I get stuck with it in the project I have no one to help out so I would fail the section of the course and not get into University. So this is quite important to me. I want to use Python to develop a Cocoa app. I know that I need PyObjc, however all details on the net seem to assume

Writing metadata to a pdf using pyobjc

孤人 提交于 2019-12-03 08:41:25
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_("mynewfile.pdf") print "pdf made" This appears to work fine (no errors to the consoled), however when