Save the contents of a Gtk.DrawingArea or Cairo pattern to an image on disk

后端 未结 2 1786
误落风尘
误落风尘 2020-12-21 22:27

I\'ve got a small PyGI project which uses a Cairo image surface, which I then scale with a surface pattern and render on a Gtk.DrawingArea.

I\'d like to write the

2条回答
  •  有刺的猬
    2020-12-21 23:22

    I found another approach, using the Cairo context passed to the handler of draw events, but it resulted in capturing a region of the parent window that was larger than the DrawingArea.

    What worked for me was to use the PixBuf as you have shown, but first calling the queue_draw() method for the DrawingArea, to force a full rendering, and waiting for the event to be processed (easy enough, I already had a draw handler). Otherwise, the resulting images can be partially undrawn.

提交回复
热议问题