~glitter-team/glitter/trunk

« back to all changes in this revision

Viewing changes to glitter/frame.py

  • Committer: Jan Jokela
  • Date: 2008-12-10 22:18:59 UTC
  • Revision ID: janjokela@gmail.com-20081210221859-zxr2ut255a7xu15x
Hi, Glitter here

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# !/usr/bin/python
 
2
# -*- coding: utf-8 -*-
 
3
 
 
4
# Glitter Toolkit
 
5
 
 
6
__authors__ = ["Jan Jokela <janjokela@gmail.com>"]
 
7
__licenses__ = ["LICENSE.LGPL"]
 
8
__description__ = "Frame widget"
 
9
 
 
10
from container import Container
 
11
from image import Image
 
12
 
 
13
class Frame(Container):
 
14
    """
 
15
    A frame widget provides a top level container for other widgets and should 
 
16
    be your top most widget in the hierarchical tree just below the Stage. 
 
17
    This because using the Stage as the top most is not a good idea since 
 
18
    unlike a Frame, it is attached to the window, or a GTK embed and thus 
 
19
    cannot be transformed. 
 
20
    
 
21
    """
 
22
    
 
23
    def __init__(self):
 
24
        """ Initialize frame """
 
25
        
 
26
        super(Frame, self).__init__()
 
27
        
 
28
        self._init_elements()
 
29
        
 
30
        self._update_style(self.style)
 
31
       
 
32
    def _init_elements(self):
 
33
        """ Initializes graphical elements """
 
34
        
 
35
        self._background_image = Image()
 
36
        self.add(self._background_image)
 
37
        
 
38
    def _update_style(self, props=None):
 
39
        """ Updates style """
 
40
        
 
41
        super(Frame, self)._update_style(props)
 
42
 
 
43
        for key, value in props:
 
44
            if key == 'background-image':
 
45
                self.background_image = value
 
46
                self._background_image.set_source(self.background_image)
 
47
                self._background_image._update_layout()                
 
48
        
 
49
    def _update_layout(self):
 
50
        """ Updates layout """
 
51
        
 
52
        super(Frame, self)._update_layout()
 
53
        
 
54
        for child in self.get_children():
 
55
            child._update_layout()
 
56
        
 
57
    def add(self, child):
 
58
        """ Overrides clutter.Actor--add(child) method; calls layout update """
 
59
        
 
60
        super(Frame, self).add(child)
 
61
        
 
62
        self._update_layout()
 
63
        
 
64
 
 
65