PyUserInput
PyUserInput copied to clipboard
Python3 OS X PyKeyboardEvent Crashes
I am using PyKeyboardEvent to listen for keyboard events on OS X, but Python 3 crashes when I run my instance of the subclass.
Code
>>> from pykeyboard import PyKeyboardEvent
>>> class KeyboardHandler(PyKeyboardEvent):
def __init__(self):
super().__init__()
def tap(self, keycode, character, press):
if press:
print(character)
>>> x=KeyboardHandler()
>>> x.run()
>>> ================================ RESTART ================================
Crash Details
http://pastebin.com/6ipbyNXL
Sweet mother of... Could you move the crash details into a pastebin or other storage, instead of making us scroll a marathon? Just keeping things tidy.
I wonder if this is a Quartz/CG problem.. IMHO pyUserInput needs a total rethink around OS X.. re: https://github.com/SavinaRoja/PyUserInput/issues/45#issuecomment-45683670
Hi, i have the same problem with python 2.7, my code is similar:
from pykeyboard import PyKeyboardEvent
class EventKeyboard(PyKeyboardEvent):
def __init__(self):
PyKeyboardEvent.__init__(self)
def tap(self, keycode, character, press):
if press:
print character
event=EventKeyboard()
event.run()
if i run this: "Segmentation fault: 11"
same issue on python2.7 osx el capitan using the same example as @7i11
IIRC, the PyKeyboardEvent API is rather unfinished. I am still rethinking pykeyboard in general because it does not do localization/internationalization right.
@SavinaRoja thanks for caring about localization/internationalization stuff, this will be realy usefull in the future
nevertheless, to fix the segfault issue on osx you/we need to allow the app to control the computer in:
System Preferences > Security & Privacy > Accessibility
add your application -in my case for developement purpose iTerm
- in the list and you're done ;-)
Maybe some inspiration could be taken from https://github.com/moses-palmer/pynput
I guess we should document the accessibility settings for Mac installation instructions?