Re: Failed to run the HotKey Example

Ronald Oussoren <[email protected]> Thu, 09 Jan 2014 14:15:29 +0100
Newsgroups gmane.comp.python.pyobjc.devel
Message-ID <[email protected]>
On 09 Jan 2014, at 14:06, Jake Wang <[email protected]> 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

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk

_______________________________________________
Pyobjc-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyobjc-dev