How to draw any GTK widget on top of Cairo surface
问题 I would like to save the looks of a GTK window, and all the buttons and other widgets it contains to a PNG or PDF file. Cairo supports drawing on such surfaces. Could I somehow ask a GTK widget to draw itself on Cairo surface? A code sample would be much appreciated, since I am a newcomer to both GTK and Cairo. Python is my language of choice. 回答1: In C, you can put your buttons and widgets in a GtkOffscreenWindow using gtk_widget_reparent() and then use gtk_offscreen_window_get_pixbuf() to