Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've made my application for Ubuntu App Showdown. When I start it from terminal using quickly run it works well. I've packaged it with quickly package and installed locally. Unfortunately it does not start. I think it's a problem with linking to css file inside my python code, but I don't know how should I link properly, so it will work after install. Output from terminal when starting installed app:

michal@michal-Inspiron-530-11:~$ easy-stopwatch
/usr/lib/python2.7/dist-packages/gi/overrides/ Warning: g_object_set_property: construct property "type" for object `Window' can't be set after construction
  Gtk.Window.__init__(self, type=type, **kwds)

(easy-stopwatch:10446): Gtk-CRITICAL **: gtk_css_section_get_file: assertion `section != NULL' failed

(easy-stopwatch:10446): Gtk-CRITICAL **: gtk_css_section_get_end_position: assertion `section != NULL' failed

(easy-stopwatch:10446): Gtk-CRITICAL **: gtk_css_section_get_end_line: assertion `section != NULL' failed
Traceback (most recent call last):
  File "/usr/bin/easy-stopwatch", line 33, in <module>
  File "/usr/lib/python2.7/dist-packages/easy_stopwatch/", line 33, in main
    window = EasyStopwatchWindow.EasyStopwatchWindow()
  File "/usr/lib/python2.7/dist-packages/easy_stopwatch_lib/", line 35, in __new__
  File "/usr/lib/python2.7/dist-packages/easy_stopwatch/", line 56, in finish_initializing
  File "/usr/lib/python2.7/dist-packages/gi/", line 43, in function
    return info.invoke(*args, **kwargs)
gi._glib.GError: <unknown>:1:0: Failed to import: Error opening file: No such file or directory

Part of my python code:

    # Styling via CSS file
    screen = Gdk.Screen.get_default()
    css_provider = Gtk.CssProvider()
    style_context = Gtk.StyleContext()
    style_context.add_provider_for_screen(screen, css_provider, Gtk.STYLE_PROVIDER_PRIORITY_USER)


After some searching I realized that quickly package does not make app to install in /opt but quickly package --extras does. After installing in /opt I've edited my python file so the link to css file looks like this:


After that my app works. I'm not sure if I can do that in the code I'd like to submit to Ubuntu App Showdown.

share|improve this question
up vote 2 down vote accepted

Don't hardcode the path in the following call, use the generic function to load media files. That will allow you to correctly load the file either during development or on an installed system.

So instead of this:


Do something along these lines:

from foo_lib.helpers import get_media_file

share|improve this answer
Thanks for the answer. – mivoligo Jul 5 '12 at 12:03
If you're happy with the answer, don't forget to mark it as the accepted one with the checkbox icon on the left ;) – David Planella Jul 5 '12 at 12:04
Sorry, but I pressed Enter and didn't post my all comment. Thanks for the answer. I've changed the code so it looks like: ` from easy_stopwatch_lib.helpers import get_media_file css_provider.load_from_path(get_media_file("gtk-style.css"))` and moved "gtk-style.css" to /data/media but after running quickly run I get: – mivoligo Jul 5 '12 at 12:10
Try to add a print get_media_file("gtk-style.css") statement and see if that returns the right CSS file path. – David Planella Jul 5 '12 at 12:52
It returns: file:////home/michal/easy-stopwatch/data/media/gtk-style.css so it looks O.K. I don't know if there should be as many //// after file:But I get the same error: – mivoligo Jul 5 '12 at 13:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.