I found this way:
GdkPixmap *backPixMap = gdk_pixmap_create_from_xpm ( window , NULL , NULL , fileName );
gdk_window_set_back_pixmap( GTK_WIDGET( window )->window , backPixMap , FALSE );
but it seems that GdkPixmap is obsolete now...
So, with GTK3, how can I set the background image of a GtkWindow?
You just need to use an Overlay. Following is an example.
class Window(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self)
self.overlay = Gtk.Overlay()
self.add(self.overlay)
self.bg = Gtk.Image()
# Load file. Optionally scale it for window
self.bg.set_from_file(BACKGROUND_IMAGE)
# Wrapping in the Scrollable make it resizable.
scrollable_wrapper = Gtk.ScrolledWindow()
scrollable_wrapper.add(self.bg)
scrollable_wrapper.set_size_request(700, 500)
self.overlay.add(scrollable_wrapper)
text = Gtk.Label("Test")
self.overlay.add_overlay(text)
self.connect('destroy', lambda w: Gtk.main_quit())
self.show_all()
Window()
Gtk.main()