Re: [Pyobjc-dev] Failed to run the HotKey Example
Brought to you by:
ronaldoussoren
From: Ronald O. <ron...@ma...> - 2014-01-09 13:16:13
|
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 |