views:

23

answers:

1

Hello there. I'm trying to make a program in python which creates a fullscreen window and includes an image, but I don't really know how to do that. I've tried to read documentations on pygtk and I've searched in both goodle and stackoverflow, without any success. Here's my current code.

def __init__(self):
    pixbuf = gtk.gdk.pixbuf_new_from_file("test.png")
    image = gtk.Image()
    self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
    self.window.fullscreen()
    self.window.show()
    image.set_from_pixbuf(pixbuf)
    image.show()

Question: how do I include an image in a window?

+2  A: 

Please provide a little more context (e.g. class definition, imports).

Do not forget to add the image object to your window (before showing image and window):

self.window.add(image)

The tutorial example adds the image to a button, but you can try adding it directly to the main window:

# an image widget to contain the pixmap
image = gtk.Image()
image.set_from_pixmap(pixmap, mask)
image.show()

# a button to contain the image widget
button = gtk.Button()
button.add(image)
window.add(button)
button.show()

button.connect("clicked", self.button_clicked)
gimel
Thanks, it worked like a charm.If you want to, you can see the whole code [here.](http://pastebin.com/TnM8tdAu)
A little context as part of a question helps in understanding. Glad to provide a solution ;-)
gimel