I am trying to create an action with the keyboard shortcut Ctrl + S in a GTK4 Python application. I am using the boilerplate code given by GNOME Builder:
def create_action(self, name, callback, shortcuts=None):
"""Add an application action.
Args:
name: the name of the action
callback: the function to be called when the action is
activated
shortcuts: an optional list of accelerators
"""
action = Gio.SimpleAction.new(name, None)
action.connect("activate", callback)
self.add_action(action)
if shortcuts:
self.set_accels_for_action(f"app.{name}", shortcuts)
to create an action inside a window like this:
self.get_application().create_action("stop", lambda *_: print('stop'), "<primary>s")
When I launch the application, I get this in the terminal:
Gtk-CRITICAL **: 20:24:56.305: Unable to parse accelerator '>': ignored request to install accelerators
How should I create an accelerator with that shortcut?