Source

Fat x Fast / FatxFast / gui / hud / frame.py

Full commit
# This file is part of FatxFast.                                                
#                                                                               
#    FatxFast is free software: you can redistribute it and/or modify           
#    it under the terms of the GNU General Public License as published by       
#    the Free Software Foundation, either version 3 of the License, or          
#    (at your option) any later version.                                        
#                                                                               
#    FatxFast is distributed in the hope that it will be useful,                
#    but WITHOUT ANY WARRANTY; without even the implied warranty of             
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              
#    GNU General Public License for more details.                               
#                                                                               
#    You should have received a copy of the GNU General Public License          
#    along with FatxFast.  If not, see <http://www.gnu.org/licenses/>.          
                                                                                
# Versioning based on:                                                          
# http://en.wikipedia.org/wiki/Versioning#Designating_development_stage         
__author__ = "dryatu (c) 2013"                                                  
__version__ = "1.2.5" 

from FatxFast.gui.containerwidget import ContainerWidget
from FatxFast.gui.textwidget import TextWidget

class Frame(ContainerWidget):

    def __init__(self, game, **kwargs):
        self.game = game
        super(Frame, self).__init__(**kwargs)

    def fetch_template(self, name):
        return self.game.manager.sceneparser.templates[name].copy()

    def create_text(self, new_attr, template="gametext"):
        attr = self.fetch_template(template)
        a = self.game.manager.sceneparser.override_attributes(attr, new_attr)
        text = TextWidget(**a)
        self.add_widget(text.name, text)
        return text