wxPython isn't loading certain gtk modules

I have been attempting to use wxPython in a simple snap for a couple of months now, and I’ve managed to get a widget appear on screen, but the text is broken, and running the snap raises multiple errors. My snapcraft.yaml file is as follows:

name: sqab-tuxbert
version: '0.1'
summary: SQAB - Statistics Quack Asparaguus Bologne
description: |
  Prints a simple message using wxPython.

grade: devel
confinement: devmode

apps:
  sqab-tuxbert:
    command: bin/sqab

parts:
#  wx:
#    plugin: python
#    source: http://downloads.sourceforge.net/project/wxpython/wxPython/2.9.5.0/wxPython-src-2.9.5.0.tar.bz2
#    build-packages:
#      - libglib2.0-dev
#      - libgtk2.0-dev
#      - libnotify-dev
#      - libgl1-mesa-dev
#    stage-packages:
#      - libgtk2.0-0
  sqab-tuxbert:
    source: https://github.com/tuxbert/sqab.git
    plugin: python
    build-packages:
      - libwebkitgtk-dev
      - libwebkitgtk-3.0-dev
      - unity-gtk2-module
      - unity-gtk3-module
      - unity-gtk-module-common
      - unity-gtk-module-autopilot
      - libjpeg-dev
      - libtiff-dev
      - libsdl1.2-dev
      - libgstreamer-plugins-base0.10-dev
      - freeglut3
      - freeglut3-dev
      - xorg-dev
      - libglw1-mesa-dev
      - libglw1-mesa
      - libgtk-3-dev
      - libgtk-3-0
      - libglu1-mesa
      - libgl1-mesa-dev
      - libglib2.0-dev
      - libgtk2.0-dev
      - libnotify-dev
      - libgstreamer1.0-dev
      - libgstreamer-plugins-base1.0-dev
      - gstreamer1.0-plugins-base
      - libcanberra-gtk-dev
      - libcanberra-gtk-module
      - libcanberra-gtk3-0
      - libcanberra-gtk3-dev
      - libwxbase3.0-dev
      - libwxgtk3.0-dev
      - libwxgtk-webview3.0-dev
    stage-packages:
      - libgtk2.0-0
      - libwxbase3.0-0v5
      - libwxgtk3.0-0v5
      - libwxgtk-webview3.0-0v5
    python-packages: [wxpython]

It manages to snap without problems, but upon running, I get a message like this:

Gtk-Message: Failed to load module "unity-gtk-module"

(sqab:2510): GdkPixbuf-WARNING **: Cannot open pixbuf loader module file '/usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders.cache': No such file or directory

This likely means that your installation is broken.
Try running the command
  gdk-pixbuf-query-loaders > /usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders.cache
to make things work again for the time being.
Gtk-Message: Failed to load module "canberra-gtk-module"
Gtk-Message: Failed to load module "canberra-gtk-module"

(sqab:2510): Gtk-WARNING **: Could not find the icon 'dialog-information-symbolic-ltr'. The 'hicolor' theme
was not found either, perhaps you need to install it.
You can get a copy from:
    http://icon-theme.freedesktop.org/releases

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed

(sqab:2510): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed

(sqab:2510): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed

(sqab:2510): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed

(sqab:2510): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed

(sqab:2510): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed

(sqab:2510): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed

(sqab:2510): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed

(sqab:2510): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): Gtk-WARNING **: Error loading theme icon 'image-missing' for stock: Icon 'image-missing' not present in theme ubuntu-mono-dark

(sqab:2510): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed

(sqab:2510): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed

The messagebox which shows up on screen looks like this:

delete

Any ideas as to what is going wrong?

1 Like

I think you’ll get most of the way towards a working snap by using the desktop-gtk2 helper:

...

apps:
  sqab-tuxbert:
    command: desktop-launch $SNAP/bin/sqab

parts:
  sqab-tuxbert:
    after: [desktop-gtk2]
    source: https://github.com/tuxbert/sqab.git
    ...

...

I’ve made the changes, but I’m getting the exact same error when I try and run the snap.

you have no plugs defined on your application. At the very least you’ll want desktop, x11, and wayland added. You might want desktop-legacy, and opengl too along with any others that your application needs e.g. home to access files in the user’s $HOME directory.

Sorry for the late reply. The only change that I haven’t retained is the change in command, as it seemed to prevent my snap from running. Anyhow, thanks for the help so far. I now am gettting text, although the error messages continue to appear and I can’t seem to get any images on my messagebox. This is what it looks like at the moment:

messagebox