Source code for tagit.controller.sidebox.tags_selection

"""

Part of the tagit module.
A copy of the license is provided with the project.
Author: Matthias Baumgartner, 2016

"""
# IMPORTS
import operator

# INNER-MODULE IMPORTS
from ..controller import DataController

# EXPORTS
__all__ = ('CSidebox_Tags_Selection', )

## CODE ##
[docs]class CSidebox_Tags_Selection(DataController): """List tags of selected images. """ def __init__(self, widget, model, settings, parent=None): super(CSidebox_Tags_Selection, self).__init__(widget, model, settings, parent) self.parent.bind(on_selection=self.update) def __del__(self): self.parent.unbind(on_selection=self.update)
[docs] def update(self, browser, selection): """Update the sidebox widget.""" tags = reduce(operator.add, map(self.model.tags.get, selection), []) tags = list(set(tags)) # unique tags = map(lambda s: s.title(), tags) # nice display self.widget.update(tags) ## EOF ##