10

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?

5

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.

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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