Function that returns a Formatoption class for modifying the fontweight

    This function returns a :class:`~psyplot.plotter.Formatoption` instance
    that modifies the weight of the given `base` formatoption

    Parameters
    ----------
    base: Formatoption
        The base formatoption instance that is used in the
        :class:`psyplot.Plotter` subclass to create the label. The instance
        must have a ``texts`` attribute which stores all the
        :class:`matplotlib.text.Text` instances.
    label_name: str
        The name of the label to use in the documentation. If None,
        it will be ``key``, where ``key`` is the
        :attr:`psyplot.plotter.Formatoption.key`` attribute of `base`
    children: list of str
        The childrens of the resulting formatoption class (besides the `base`
        formatoption which is included anyway)
    parents: list of str
        The parents of the resulting formatoption class (besides the `base`
        the properties formatoption from `base` (see :func:`label_props`))
    dependencies: list of str
        The dependencies of the formatoption

    Returns
    -------
    Formatoption
        The formatoption instance that modifies the fontweight of `base`

    See Also
    --------
    label_size, label_props, Figtitle, Title

def label_weight(base, label_name=None, children=[], parents=[],
                 dependencies=[]):
    """
    Function that returns a Formatoption class for modifying the fontweight

    This function returns a :class:`~psyplot.plotter.Formatoption` instance
    that modifies the weight of the given `base` formatoption

    Parameters
    ----------
    base: Formatoption
        The base formatoption instance that is used in the
        :class:`psyplot.Plotter` subclass to create the label. The instance
        must have a ``texts`` attribute which stores all the
        :class:`matplotlib.text.Text` instances.
    label_name: str
        The name of the label to use in the documentation. If None,
        it will be ``key``, where ``key`` is the
        :attr:`psyplot.plotter.Formatoption.key`` attribute of `base`
    children: list of str
        The childrens of the resulting formatoption class (besides the `base`
        formatoption which is included anyway)
    parents: list of str
        The parents of the resulting formatoption class (besides the `base`
        the properties formatoption from `base` (see :func:`label_props`))
    dependencies: list of str
        The dependencies of the formatoption

    Returns
    -------
    Formatoption
        The formatoption instance that modifies the fontweight of `base`

    See Also
    --------
    label_size, label_props, Figtitle, Title"""
    label_name = label_name or base.key
    cl_children = children
    cl_parents = parents
    cl_dependencies = dependencies

    class LabelWeight(Formatoption):
        __doc__ = """
        Set the fontweight of the %s

        Possible types
        --------------
        %%(fontweights)s

        See Also
        --------
        %s, %s, %s""" % (label_name, base.key, base.key + 'size',
                         base.key + 'props')
        children = [base.key] + \
            cl_children
        parent = [base.key + 'props'] + cl_parents
        dependencies = cl_dependencies

        group = 'labels'

        name = 'Font weight of ' + (base.name or base.key)

        def update(self, value):
            for text in getattr(self, base.key).texts:
                text.set_weight(value)

        def get_fmt_widget(self, parent, project):
            """Get a widget with the different font weights"""
            from psy_simple.widgets.texts import FontWeightWidget
            return FontWeightWidget(
                parent, self, next(iter(getattr(self, base.key).texts), None),
                base)

    return LabelWeight(base.key + 'weight')