I posted an issue on gitlab (https://gitlab.gnome.org/GNOME/pygobject/-/issues/439), but was told to post it here instead.
I have an application written using pygobject with Gtk4. I have been working on a feature which allows the application to take screenshots of itself for documentation purposes.
I believe the “front door” for taking a screenshot would be:
- Get a
Gtk.Snapshot
- Grab the main
Gsk.RenderNode
from it. - Use a
Gsk.Renderer
to convert theRenderNode
to aGdk.Texture
- Save the
Gdk.Texture
to a file.
There are other ways, involving cairo
, but every way I’ve found depends on Gsk
in some way or another.
I have noticed a few issues when using these Gsk
objects:
-
Gsk.CairoRenderer.render_texture
seems to expect aGObject
as the first argument, but it actually takes aGskRenderNode
which is not aGObject
. As a result, I don’t believe it can be used. -
GskRenderNode.serialize
causes the application to seg. fault. -
GskRenderNode.draw
to acairo.Context
causes the application to seg. fault.
My questions are as follows: Is Gsk supported in pygobject
? Will it be supported in the future? What is the best way to take a screenshot of the application?