Re: [Pyobjc-dev] Failed to run the HotKey Example
Brought to you by:
ronaldoussoren
From: Jake W. <del...@gm...> - 2014-01-09 13:28:42
|
I just ran this: python -c "import Cocoa; print(Cocoa.__file__)" and I got: /Library/Python/2.7/site-packages/pyobjc_framework_Cocoa-2.5.1-py2.7-macosx-10.8-intel.egg/AppKit/_AppKit.so Thanks for the analysis regarding the PyQT question. As long as the hotkey registration code doesn't rely on NSApplication and can co-exist with PyQT, it should work. I will do more investigation on this later. Cheers, Jake On Thu, Jan 9, 2014 at 9:15 PM, Ronald Oussoren <ron...@ma...>wrote: > > On 09 Jan 2014, at 14:06, Jake Wang <del...@gm...> wrote: > > Hi Ronald, > > I just tried your new version of the example code. > > 1. When I built via: python setup.py py2app > > and run it with > > arch -i386 dist/HotKey.app/Contents/MacOS/HotKey > > 'print(sys.prefix)' printed the following line: > > /Users/jakew/Desktop/HotKeyPython/dist/HotKey.app/Contents/Resources > > > and the app could be run correctly. > > 2. But if I built via: python setup.py py2app -A > > and run it with > > arch -i386 dist/HotKey.app/Contents/MacOS/HotKey > > 'print(sys.prefix)' printed the following line: > > /Library/Frameworks/Python.framework/Versions/2.7 > > and the app failed to start duo to an error: 'ImportError: No module > named Cocoa’ > > > That’s odd. What is printed if you run “python -c ‘import Cocoa; > print(Cocoa.__file__)’’? > > > It's good that the non-alias way worked! Thanks a lot. > > I would like to use this HotKey feature with a PyQT application, so is it > possible > to not use NSApplication to RegisterEventHotKey, and instead, do it in > PyQT application > class? Or, is there other ways to make the HotKey function work with PyQT? > > > I don’t know because I’ve never used PyQt on OSX. The registration code in > finishLaunching should work just as well in a Qt application (that just > uses the Carbon package to register a hotkey), but I don’t know how you’d > inspect native events in PyQt (the code in sendEvent_). > > Ronald > > |