Skip to content
Advertisement

How do you add an inline image to PyGObject 3?

I want to put inline images into my PyGObject 3 programs so they won’t have to be loaded from disk. YoLinux shows how to edit an XPM file so its text can be inserted into Python code. The free e-book “PyGTK 2.0 Tutorial” by John Finlay gives two code examples. All that’s for PyGTK 2 not gi / PyGObject 3. It doesn’t have to be XPM data, that’s just an easy way to do it in PyGTK 2. Below is an edited version of example pixmap.py

How could this working example be changed to PyGObject 3 or is there another working example of an easier way to add an inline image to PyGObject 3?

JavaScript

Advertisement

Answer

This is a straightforward port of your example to PyGObject 3. The solution makes use of the GdkPixbuf.Pixbuf.new_from_xpm_data() function to create the image.

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement