# Path: pyglet_gui/core.py
# class Controller(Managed):
#     def __init__(self):
#         Managed.__init__(self)
# 
#     def set_manager(self, manager):
#         Managed.set_manager(self, manager)
#         manager.add_controller(self)
# 
#     def delete(self):
#         self._manager.remove_controller(self)
#         super(Controller, self).delete()


from collections import OrderedDict
from pyglet_gui.core import Controller
    def select(self):
        self._selector.deselect()
        self._selector.select(self._option_name)


class Selector:
    def __init__(self, options, labels=None, on_select=None, selected=None):
        assert len(options) > 0
        assert None not in options
        assert labels is None or len(options) == len(labels)
        assert selected is None or selected in options

        if labels is None:
            labels = options

        self._selected = selected

        widget_options = self._make_options(options, labels)
        self._options = OrderedDict(list(zip(options, widget_options)))

        self._on_select = lambda x: x
        if on_select is not None:
            self._on_select = on_select

    def _make_options(self, options, labels):
        # has to be implemented.
        raise NotImplementedError

    def select(self, option_name):
        if self._selected is not None:

# Path: pyglet_gui/core.py
# class Controller(Managed):
#     def __init__(self):
#         Managed.__init__(self)
# 
#     def set_manager(self, manager):
#         Managed.set_manager(self, manager)
#         manager.add_controller(self)
# 
#     def delete(self):
#         self._manager.remove_controller(self)
#         super(Controller, self).delete()


# Path: pyglet_gui/controllers.py
from collections import OrderedDict
from pyglet_gui.core import Controller

    def select(self):
        self._selector.deselect()
        self._selector.select(self._option_name)


class Selector:
    def __init__(self, options, labels=None, on_select=None, selected=None):
        assert len(options) > 0
        assert None not in options
        assert labels is None or len(options) == len(labels)
        assert selected is None or selected in options

        if labels is None:
            labels = options

        self._selected = selected

        widget_options = self._make_options(options, labels)
        self._options = OrderedDict(list(zip(options, widget_options)))

        self._on_select = lambda x: x
        if on_select is not None:
            self._on_select = on_select

    def _make_options(self, options, labels):
        # has to be implemented.
        raise NotImplementedError

    def select(self, option_name):
        if self._selected is not None:

            self._options[self._selected].change_state()