I want to save cairo drawing in pygtk to disk.
#!/usr/bin/env python3
import cairo
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
def draw(da, ctx):
# ...
# How to get the surface ?
surface.write_to_png("image.png")
def main():
win = Gtk.Window()
da = Gtk.DrawingArea()
win.add(da)
da.connect('draw', draw)
win.show_all()
Gtk.main()
if __name__ == '__main__':
main()
How to get the surface? Or is there any better method to save the drawing to disk?
I found it.