Hi Jon,

Jon Danao wrote:
> Hi guys!
> 
> I was able to put background image behind the interface. This is very
> crude but it works. With zero knowledge in Python or Pigment, I'm pretty
> happy with it. 
> 
> To be able to achieve this, you have to remember that visual objects in
> Elisa float in 3D space. Coming from Flash/ActionScript, it took me a
> while to realize this. I thought I can layer objects using depth or
> z-index. 

In fact it's the same idea, really. Pigment 0.3 manipulates 2D objects
in a 3D space. This will change with pigment 0.5 which is currently
under active development: it will provide real 3D scenegraph capabilities.

> ------------------------------------------------------------
> Steps:
> 
> 1: Define background image (back_image) in resources.conf. Place image
> inside theme folder.
> 
> defaults {
>   basedir: 'theme';
> }
> 
> elisa.plugins.poblesec {
>   enter_button: 'enter_button.png';
>   back_button: 'back_button.png';
>   waiting_icon: 'waiting.png';
>   scanning_icon: 'scanning.png';
>   key_icon: 'key.png';
>   back_image: 'wallpaper_02.png'; 
> }
> 
> 
> 2: Edit main.py. 
> 
> #insert these statements at the top
> from elisa.plugins.pigment.graph.image import Image
> from elisa.plugins.pigment.widgets.theme import Theme
> 
> #insert this code inside def set_frontend()
> new_size = 1.6
> new_coord = (new_size - 1)/2 * -1
> 
> theme = Theme.get_default()
> wallpaper_resource =
> theme.get_resource('elisa.plugins.poblesec.back_image')        
> 
> self.wallpaper = Image()
> self.wallpaper.bg_a = 0
> self.wallpaper.size = (new_size, new_size)
> self.wallpaper.position = (new_coord, new_coord, -400.0)

You don't have to place it that far away! -0.1 should do.
In general it's a good practice to first add the new widget to its
parent controller's widget and then modify its size/position properties.
Since sizes are relatives, you could just set the size of your image to
(1.0, 1.0) and its position to (0.0, 0.0, -0.1).

> self.wallpaper.set_from_file(wallpaper_resource)
> self.wallpaper.visible = True
> self.widget.add(self.wallpaper)
> ------------------------------------------------------------
> 
> Thats it!! Screenshot here
> - http://danao.org/elisa/elisa_with_background.jpg

Nice :)

> I have a question though. This is easily done in Windows build. But this
> does not work in Ubuntu. It still shows a black background. I discovered
> the Linux build is not able to read my back_image reference in
> resources.conf. Why is that? I thought I could just copy the entire
> poblesec folder from Windows and place it in Ubuntu. 

One stupid question: did you copy over the image file
('wallpaper_02.png') to poblesec/theme?

I don't know how you are developing on linux but I advise you to use the
bzr branch at lp:elisa (see http://elisa.fluendo.com/participate/, the
"Getting started" section).

> Cheers! 
>  
> Jon Danao
> danao.org <http://danao.org>
> <http://danao.org>

Cheers,

Olivier

Reply via email to