~glitter-team/glitter/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# !/usr/bin/python
# -*- coding: utf-8 -*-

# Glitter Toolkit

__authors__ = ["Jan Jokela <janjokela@gmail.com>"]
__licenses__ = ["LICENSE.LGPL"]
__description__ = "Frame widget"

from container import Container
from image import Image

class Frame(Container):
    """
    A frame widget provides a top level container for other widgets and should 
    be your topmost widget in the hierarchical tree just below the Stage. 
    This because using the Stage as the top most is not a good idea since 
    unlike a Frame, it is attached to the window, or a GTK embed and thus 
    cannot be transformed. 
    
    """
    
    def __init__(self):
        """ Initialize frame """
        
        super(Frame, self).__init__()
        
        self._init_elements()
        
        self._update_style(self.style)
       
    def _init_elements(self):
        """ Initializes graphical elements """
        
        self._background_image = Image()
        self.add(self._background_image)
        
    def _update_style(self, props=None):
        """ Updates style """
        
        super(Frame, self)._update_style(props)

        for key, value in props:
            if key == 'background-image':
                self.background_image = value
                self._background_image.set_source(self.background_image)
                self._background_image._update_layout()              
        
    def _update_layout(self):
        """ Updates layout """
        
        super(Frame, self)._update_layout()
        
        for child in self.get_children():
            child._update_layout()
        
    def add(self, child):
        """ Overrides clutter.Actor--add(child) method; calls layout update """
        
        super(Frame, self).add(child)
        
        self._update_layout()