pyobjc

Python capture Keystrokes values in text file on OS X

≡放荡痞女 提交于 2019-12-03 08:23:38
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 and analyze the frequency etc... Thanks in advance ;) #!/usr/bin/python # -*- coding: utf-8 -*- from

PyObjC development with Xcode 3.2

断了今生、忘了曾经 提交于 2019-12-03 02:04:53
问题 Xcode 3.2 has removed the default templates for the scripting languages (Ruby, Python etc). How do I find these templates to use in Xcode 3.2? Would I need to add anything else to Xcode to support working with and 'building' PyObjC programs? Additionally, is there any documentation and/or resources that would help me get into PyObjC (and Cocoa), taking into account I am already a Python guy? 回答1: Apple now encourages people to get the templates directly from the PyObjC project. There's a nice

PyObjc and Cocoa on Snow Leopard

大城市里の小女人 提交于 2019-12-03 00:49:42
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 it is pre-installed. Apparently this is the case with Leopard and Snow Leopard but I don't seem to

PyObjC development with Xcode 3.2

别等时光非礼了梦想. 提交于 2019-12-02 17:11:53
Xcode 3.2 has removed the default templates for the scripting languages (Ruby, Python etc). How do I find these templates to use in Xcode 3.2? Would I need to add anything else to Xcode to support working with and 'building' PyObjC programs? Additionally, is there any documentation and/or resources that would help me get into PyObjC (and Cocoa), taking into account I am already a Python guy? Apple now encourages people to get the templates directly from the PyObjC project. There's a nice thread of explanation archived on Cocoabuilder , with the following advice from bbum: You'll need to

ImportError: No module named pyobjc

社会主义新天地 提交于 2019-12-02 14:51:20
问题 I am new to Python. I am running Mac OS X 10.8.2, Python 2.7.3, Xcode 4.5.1. I am not able to import pyobjc to python.I used easy_install pyobjc or manually downloading it from http://pypi.python.org/pypi/pyobjc/2.3 and running python setup.py install . Here is a screenshot of my site-packages folder How do I solve this? Here is a screenshot of sys.path.PyOBJc is present in sys.path 回答1: I don't see a .pth file for pyobjc in your site-packages directory there. .pth files, placed inside a

Python code to detect dark mode in OS X El Capitan to change the status bar menu icon

谁说我不能喝 提交于 2019-12-02 11:58:55
问题 I have objective C code to detect dark mode to change the status bar: [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(darkModeChanged:) name:@"AppleInterfaceThemeChangedNotification" object:nil]; Similarly, how can we do the same in python? 回答1: Try these following lines wherever you want to detect the mode (dark mode or light mode). center = NSDistributedNotificationCenter.defaultCenter() center.addObserver_selector_name_object_(self,"enableDarkMode",

pyobjc indexed accessor method with range

送分小仙女□ 提交于 2019-12-01 22:29:38
问题 I'm trying to implement an indexed accessor method for my model class in Python, as per the KVC guide. I want to use the optional ranged method, to load multiple objects at once for performance reasons. The method takes a pointer to a C-array buffer which my method needs to copy the objects into. I've tried something like the following, which doesn't work. How do I accomplish this? @objc.accessor # i've also tried @objc.signature('v@:o^@') def getFoos_range_(self, range): return self._some

pyobjc indexed accessor method with range

Deadly 提交于 2019-12-01 21:07:00
I'm trying to implement an indexed accessor method for my model class in Python, as per the KVC guide . I want to use the optional ranged method, to load multiple objects at once for performance reasons. The method takes a pointer to a C-array buffer which my method needs to copy the objects into. I've tried something like the following, which doesn't work. How do I accomplish this? @objc.accessor # i've also tried @objc.signature('v@:o^@') def getFoos_range_(self, range): return self._some_array[range.location:range.location + range.length] Edit : I finally found the type encodings reference

XCode 3.2 Ruby and Python templates

狂风中的少年 提交于 2019-12-01 16:41:39
问题 Under xcode 3.2 my ObjectiveC + Python/Ruby projects can still be opened updated and compiled, but you cannot create new projects. Given that all traces of ruby and python are missing from xcode 3.2 (ie create project and add new ruby/python file), is there an easy way to get the templates installed again? I found some info about copying them into a folder somewhere, but I cant seem to get it to work, I suspect the folder location has changed for 3.2. 回答1: The folder for application templates

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

我怕爱的太早我们不能终老 提交于 2019-11-30 16:16:42
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. What you are looking for is, NSDistributedNotificationCenter or NSWorkspace , these cocoa classes post notifications