Hi

I'd like to embed images into my TextBuffer, and then center them.

The code snippet at the moment is:

    tv = gtk.TextView ()
    buf = tv.get_buffer ()

    buf.create_tag ('center-image', justification = gtk.JUSTIFY_CENTER)

    ...

    pixbuf = gtk.gdk.pixbuf_new_from_file ('path/to/image.png')

    ...

    # putting the image at the end.
    sob, eob = buf.get_bounds ()

    mark = buf.create_mark (None, eob)

    buf.insert_pixbuf (eob, pixbuf)

    buf.apply_style_by_name ('center-image', buf.get_iter_from_mark (mark), 
buf.getbounds ()[1])

    ...

It maybe a bit awkward, while I think I understand every step :)
However, the resulting image does not get centered.

Is something missing from the code which actually does the right thing?

(FWIW, gtk is of version 2.4.3, pygtk is of version 2.2.0)

Regards

--
Misha

Attachment: signature.asc
Description: Digital signature

_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to