Hi,
What I'm wanting to accomplish is to have an image preview, with a few
rows of text beneath the image show up on the preview area of the
FileChooserDialog.
What I have so far that works:
def update_preview(self, chooser):
filename = chooser.get_preview_filename()
try:
thumb = gtk.gdk.pixbuf_new_from_file_at_size(filename,
300, 300)
image = gtk.Image()
image.set_from_pixbuf(thumb)
chooser.set_preview_widget(image)
active = True
except:
active = False
chooser.set_preview_widget_active(active)
This works perfectly as you'd expect, for supported image types, it
shows a 300px preview image, and for unsupported filetypes it shows
nothing with no errors.
However, if I try the obvious thing of embedding the image into a
vbox, it completely stops working.
def update_preview(self, chooser):
filename = chooser.get_preview_filename()
try:
thumb = gtk.gdk.pixbuf_new_from_file_at_size(filename,
300, 300)
image = gtk.Image()
image.set_from_pixbuf(thumb)
vbox = gtk.VBox(False, 12)
vbox.add(image)
chooser.set_preview_widget(vbox)
active = True
except (TypeError, glib.GError):
active = False
chooser.set_preview_widget_active(active)
Instead of showing the preview image as before, it simply shows an
ellipses ("...") with no image, and no errors of any kind (nothing
printed to the terminal, the program continues running fine, etc).
I am completely baffled by this. Why can't I just drop in a vbox as
the preview widget? I don't see anything at all in the documentation
stating that gtk.Image() is the only acceptable preview widget type.
Quite the opposite, it implies that any Gtk.Widget can be used, of
which VBox is certainly one.
Adding a few Gtk.Label()s to the vbox also didn't help. What gives?
Thanks.
--
http://exolucere.ca
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/