pyobjc

How do I get rid of unwanted debug output when importing pyobjc AppKit with Python 3.7

烈酒焚心 提交于 2020-01-14 02:21:26
问题 A script consisting of a single statement import AppKit Prints the following to stdout/stderr with Python 3.7 (maybe also other 3.x versions but not with Python 2.7) bool b'B' <classmethod object at 0x10b41e510> <function ivar.bool at 0x10b464440> char b'c' <classmethod object at 0x10b41e4d0> <function ivar.char at 0x10b4644d0> int b'i' <classmethod object at 0x10b41e0d0> <function ivar.int at 0x10b464560> short b's' <classmethod object at 0x10b41e210> <function ivar.short at 0x10b4645f0>

NSUserNotificationCenter.defaultUserNotificationCenter() returning None using PyInstaller

早过忘川 提交于 2020-01-13 13:35:11
问题 I am trying to put notification to notification centre (Mac OSX) I am using PyObjC bindings to use cocoa api's from our python application. I am using following code snippet : import Foundation¬ import objc¬ NSUserNotification = objc.lookUpClass('NSUserNotification')¬ NSUserNotificationCenter = objc.lookUpClass('NSUserNotificationCenter')¬ notification = NSUserNotification.alloc().init()¬ notification.setTitle_("TestTitle")¬ notification.setInformativeText_("This is sample text")¬ center =

Using pyobjc imports in PyDev in Eclipse on Mac OS X

烈酒焚心 提交于 2020-01-03 05:19:06
问题 I've installed and configured PyDev version 1.6.5.2011020317 inside Eclipse, running on Mac OS X 10.6.6: Version: Helios Service Release 1 Build id: 20100917-0705 I used 'Auto Config' to set up my Python interpreter: it correctly found /usr/bin/python (which is Python version 2.6.1) and added various system folders to the PYTHONPATH , including /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC . Now that path is the correct path to the Foundation module in OS X

Install PyObjC on Python 2.6 on OS X 10.5?

怎甘沉沦 提交于 2020-01-02 23:22:32
问题 OS X 10.5.8 came with Python 2.5, and had PyObjC already installed. I installed Python 2.6 from the python.org site, and PyObjC isn't there. I can't find a download to install PyObjC on my Python 2.6 install. Is checking out the PyObjC trunk and trying to build it my only choice? Will that work "out of the box"? 回答1: Apple includes PyObjC with their Pythons that come with OS X 10.5 and 10.6 . It is not part of the python.org installers. But it should be easy enough to install. Just install

Is it possible to call a Python module from ObjC?

a 夏天 提交于 2020-01-01 05:00:07
问题 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"]; 回答1: As mentioned in Alex Martelli's answer (although the link in the mailing-list message was broken, it should be https://docs.python.org

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

故事扮演 提交于 2019-12-30 04:33:04
问题 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().statusItemWithLength_(NSVariableStatusItemLength) statusItem.setTitle_(u"12%") statusItem.setHighlightMode_(TRUE) statusItem.setEnabled_(TRUE) However, when I launch the

Can't access NSPasteboard using PyObjC

邮差的信 提交于 2019-12-25 12:00:29
问题 I'm trying to read OSX Clipboard using PyObjC. Inside python shell import AppKit >>> clip = AppKit.NSPasteboard.generalPasteboard() >>> dir(clip) ['__class__', '__delattr__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__'] Many pasteboard attributes are missing. So clip.stringForType_(AppKit.NSStringPboardType) results in AttributeError. 回答1: Here's some

How to use Mac OS X NSEvents within wxPython application?

谁都会走 提交于 2019-12-25 08:32:08
问题 I am writing an application that has to react to system wide keypresses on Mac OS X. So I found some key logger examples that should work and hit a wall, because all examples are based on NSSharedApplication() and PyObjC AppHelper.runEventLoop() while my application is written in wxPython. Here I post a modification of the simplest example from https://github.com/ljos that I thought it should work. But it does not. from AppKit import * import wx class AppDelegate(NSObject): def

Integration issue with PyObjC and TKinter

风流意气都作罢 提交于 2019-12-25 03:48:08
问题 The following simple code: from PyObjCTools import AppHelper import AppKit import Tkinter class App(AppKit.NSApplication): def finishLaunching(self): self.root=Tkinter.Tk() _=App.sharedApplication() AppHelper.runEventLoop() yields the following exception: Python[23717:d07] -[App _setup:]: unrecognized selector sent to instance 0x105d05340 What am I doing wrong? 回答1: I don't think you can mix Tkinter and Cocoa toolkits so interchangeably. self.root is an attribute on the class App , which

Converting CGImage to python image (pil/opencv)

谁说胖子不能爱 提交于 2019-12-25 02:51:28
问题 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