# Path: pyglet_gui/theme/theme.py
# class Theme(ScopedDict):
#     """
#     A theme is a scoped dictionary that
#     maps specific keys to specific templates.
#     It is initialized by a dictionary (json-like) and by a resource path.
#     It maps resources in the dictionary to resources in the path,
#     initializing the correct template accordingly.
#     """
#     def __init__(self, dictionary, resources_path):
#         ScopedDict.__init__(self, dictionary, None)
# 
#         self._parsers = [TextureParser(resources_path)]
# 
#         self.build(self, dictionary)
# 
#     def update(self, E=None, **F):
#         super(Theme, self).update(E, **F)
#         self.build(self, E)
# 
#     def build_element(self, key, value, target):
# 
#         for parser in self._parsers:
#             if parser.condition_fulfilled(key):
#                 target[key] = parser.parse_element(value)
#                 # we only parse one element by parser.
#                 # if it is parsed, we are done.
#                 return
# 
#         # if value is a non-parsed dict, we add a new depth
#         # and build against the new depth.
#         if isinstance(value, dict):
#             target[key] = ScopedDict(parent=target)
#             self.build(target[key], value)
#         else:
#             target[key] = value
# 
#     def build(self, target, input_dict):
#         """
#         The main function of theme. Called during initialization,
#         it crawls the input_dict and populates
#         'target' with templates built from the dict.
#         """
#         for key, value in input_dict.items():
#             self.build_element(key, value, target)


import unittest
import pyglet
from pyglet_gui.theme import Theme
        path = ['first depth', 'other second depth']
        self.assertEqual(theme[path], [1, 1, 1, 1])

    def test_load_texture(self):
        theme = Theme({'first depth': {'image': 'panel.png'}}, 'theme')

        # panel is an 32x32 image.
        self.assertEqual(theme['first depth']['image'].width, 32)
        self.assertEqual(theme['first depth']['image'].height, 32)

    def test_load_texture_with_dictionary(self):
        theme = Theme({'first depth': {'image': {'source': 'panel.png'}}}, 'theme')

        # panel is a 32x32 image.
        self.assertEqual(theme['first depth']['image'].width, 32)
        self.assertEqual(theme['first depth']['image'].height, 32)

    def test_load_texture_with_region(self):
        theme = Theme(
            {'first depth':
                 {'image':
                      {'source': 'panel.png', 'region': [0, 0, 16, 16]}
                 }
            }, 'theme')

        # region is a 16x16 image.
        self.assertEqual(theme['first depth']['image'].width, 16)
        self.assertEqual(theme['first depth']['image'].height, 16)

    def test_load_frame(self):

# Path: pyglet_gui/theme/theme.py
# class Theme(ScopedDict):
#     """
#     A theme is a scoped dictionary that
#     maps specific keys to specific templates.
#     It is initialized by a dictionary (json-like) and by a resource path.
#     It maps resources in the dictionary to resources in the path,
#     initializing the correct template accordingly.
#     """
#     def __init__(self, dictionary, resources_path):
#         ScopedDict.__init__(self, dictionary, None)
# 
#         self._parsers = [TextureParser(resources_path)]
# 
#         self.build(self, dictionary)
# 
#     def update(self, E=None, **F):
#         super(Theme, self).update(E, **F)
#         self.build(self, E)
# 
#     def build_element(self, key, value, target):
# 
#         for parser in self._parsers:
#             if parser.condition_fulfilled(key):
#                 target[key] = parser.parse_element(value)
#                 # we only parse one element by parser.
#                 # if it is parsed, we are done.
#                 return
# 
#         # if value is a non-parsed dict, we add a new depth
#         # and build against the new depth.
#         if isinstance(value, dict):
#             target[key] = ScopedDict(parent=target)
#             self.build(target[key], value)
#         else:
#             target[key] = value
# 
#     def build(self, target, input_dict):
#         """
#         The main function of theme. Called during initialization,
#         it crawls the input_dict and populates
#         'target' with templates built from the dict.
#         """
#         for key, value in input_dict.items():
#             self.build_element(key, value, target)


# Path: tests/test_theme.py
import unittest
import pyglet
from pyglet_gui.theme import Theme

        path = ['first depth', 'other second depth']
        self.assertEqual(theme[path], [1, 1, 1, 1])

    def test_load_texture(self):
        theme = Theme({'first depth': {'image': 'panel.png'}}, 'theme')

        # panel is an 32x32 image.
        self.assertEqual(theme['first depth']['image'].width, 32)
        self.assertEqual(theme['first depth']['image'].height, 32)

    def test_load_texture_with_dictionary(self):
        theme = Theme({'first depth': {'image': {'source': 'panel.png'}}}, 'theme')

        # panel is a 32x32 image.
        self.assertEqual(theme['first depth']['image'].width, 32)
        self.assertEqual(theme['first depth']['image'].height, 32)

    def test_load_texture_with_region(self):
        theme = Theme(
            {'first depth':
                 {'image':
                      {'source': 'panel.png', 'region': [0, 0, 16, 16]}
                 }
            }, 'theme')

        # region is a 16x16 image.
        self.assertEqual(theme['first depth']['image'].width, 16)
        self.assertEqual(theme['first depth']['image'].height, 16)

    def test_load_frame(self):

        theme = Theme(