TypeError: No means to translate argument or return value for 'GdkKeyEvent'
When using a Gtk.EventControllerKey()
to obtain key-pressed
events, the following error is thrown when calling get_current_event()
in the callback:
Traceback (most recent call last):
File "/app/share/memoki/memoki/record_window.py", line 55, in _on_key_pressed
event = event_controller.get_current_event()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: No means to translate argument or return value for 'GdkKeyEvent'
The same logic works in vala (I'm porting a personal project from vala to python).
Here are the relevant parts of the python code:
def _setup_event_controller(self):
event_controller = Gtk.EventControllerKey()
event_controller.connect("key-pressed", self._on_key_pressed)
self.add_controller(event_controller)
...
def _on_key_pressed(self, event_controller, key, unused, mod):
event = event_controller.get_current_event()
...
Thank you for all the great work on pygobject, up until this roadblock porting was very smooth and satisfying!