Thomi
Thomi

Reputation: 11808

Using Python Gtk3 bindings without X11

I have a small application written in python that uses the Python Gtk3 bindings. Part of the application loads icons from the system icon theme, like this:

def get_icon(name):
    from gi.repository import Gtk
    icon_theme = Gtk.IconTheme()
    if icon_theme.has_icon(name):
        return icon_theme.load_icon("status-red", 32, 0)

This does exactly what I want - loads an icon and gives me a GdkPixbuf.Pixbuf instance.

The problem comes when my unit tests run. I have tests that test this code, and everything works fine if the tests are run on a developer machine.

However, the tests are run automatically before a package is built (as part of our CI process), and application packages are built on a headless server. So my question is: Is there a way to use just the IconTheme class from Gtk3 without requiring X11 to be running?

Upvotes: 1

Views: 1043

Answers (1)

Johan Dahlin
Johan Dahlin

Reputation: 26496

There's no way to use a gtk+ compiled against X11 without a DISPLAY.

But you can always run the testsuite inside xvfb, an X server using virtual framebuffer, that way you don't need to run from an existing terminal, but you'll still require X. It's pretty simple;

xvfb-run.sh python testsuite.py

Upvotes: 2

Related Questions