I need to generate keyboard events for my app running on a Raspberry Pi with no keyboard attached. The user has requested a grid of buttons with numbers, etc on one the side of the app. In years gone by (Gtk 3.20) this code used to work:
Note that Gdk.Seat is a relatively new type introduced in GTK 3.20. If you need to support older GTK releases, then you should use Gdk.DeviceManager to get the virtual keyboard device.
Do you mean the warning above actually is preventing the event from taking place? This post python 3.x - Remove focus from TextEntry - Stack Overflow is dealing with a similar scenario and it works for me but not the OP. I’m on Ubuntu 22.04 LTS, using latest version of Gtk3.
I tried using Gdk.EventKey() at first and couldn’t get it to work. I tried to use it again just now with the code below, it works but it kept spitting that same warning. Meanwhile, using Gdk.Event() works with no warning for me. Also, I just found out I can comment out all these attributes and the event still works for me, but I’m leaving them in for clarity.