Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am writing a project with Quickly and GTK 3 and I want to use the get_media_file() helper so I can load an icon in my data/media directory.

I can't see how I use get_media_file() with the latest quickly; it looks like the Quickly helpers have changed.

Can anyone provide me with some sample code of how this works?

share|improve this question
add comment

2 Answers

Tell me if by 'latest' you don't mean the one that ships with 11.10, but this is how to use the function here:

>>> from hello_lib.helpers import get_media_file
>>> get_media_file("hello.svg")
file:////home/stefano/hello/data/media/hello.svg

"hello.svg" can be any fragment of a path (like ../media/hello.svg or stuff/hello.svg). I.e. get_media_file(f) is the equivalent of

"file://" + os.path.join(get_data_path(), "media", f)

And get_data_path() will return /home/stefano/hello/data.

These functions are defined in hello/hello_lib/helpers.py and hello/hello_lib/helloconfig.py.

share|improve this answer
add comment

It seems you just give it the name of the file in your data/media directory.

For example, if you want data/media/foo.png, you just call get_media_file('foo.png'). This will return a file:/// URI of the absolute path to foo.png.

share|improve this answer
add comment

Your Answer

 
discard

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.