I keep getting the following error:
AttributeError: Caribou instance has no attribute 'on_key_up'
The problem is, I’m pretty sure I do have that attribute…
Here are some excerpts from my code (from caribou.py):
def on_key_up(self, event):
if event.event_string == "Shift_R":
_r_shift_down = False
elif event.event_string == "Shift_L":
_l_shift_down = False
And this is the line that is causing the error:
pyatspi.Registry.registerKeystrokeListener(caribou.on_key_up, mask=None, kind=(pyatspi.KEY_RELEASED_EVENT,))
Anybody see what I’m doing wrong?
Thanks!
edit: Whoops–here’s how I create the caribou instance:
caribou = Caribou()
The OP mentions in a comment that
dir(caribou)gives him:so it definitely looks at that point that
caribouis a module — nothing else would normally have__builtins__etc. The error message however clearly mentions aCaribou instance— so I imagine that something else must be happening between thatdircall and the following attempt to accesscaribou.on_key_up.Clearly the OP is having some multiple use of that beloved
caribouidentifier (at some point it’s bound to a Caribou instance, but at other times it’s clearly a module, and indeed the OP does mention acaribou.pywhich is clearly going to become a module namedcaribouwhen imported).So my recommendation is to clarify naming. For example, use
instead of binding one more value to the
caribouname, and replace all uses ofcaribouwhich are supposed to be the instance (not the module) withcaribou_instance. That may give you a different error, which could be more informative.