Component

class mnemosyne.libmnemosyne.component.Component(component_manager)

Base class of components that are registered with the component manager. This is a list of component types: config, log, database, scheduler, stopwatch, translator, filter, card_type, card_type_converter, card_type_widget, generic_card_type_widget, ui_component, renderer, controller, main_widget, review_controller, review_widget, file format, plugin, hook, activity_criterion, criterion_applier, statistics_page, all the abstract dialogs, ...

‘used_for’ can store certain relationships between components, e.g. a card type widget is used for a certain card type.

Most of the time, instances are stored here, apart from widgets when classes are stored. (Instantiating a complex widget can take a lot of time on a mobile device, and should be done lazily.) Only the main widget is stored as an instance here.

When ‘instantiate == LATER’, the component is lazily created when needed. The instance is not cached for subsequent reuse, as these widgets typically can become obsolete/overwritten by plugins.

Each component has access to all of the context of the other components because it hold a reference to the user’s component manager.

We need to pass the context of the component manager already in the constructor, as many component make use of it in their __init__ method. This means that derived components should always call the Component.__init__ if they provide their own constructor.

activate()
Initialisation code called when the component is about to do actual work, and which can’t happen in the constructor, e.g. because components on which it relies have not yet been registered.
card_type_by_id(id)
card_types()
config()
configuration_widgets()
controller()
database()
deactivate()
filters()
log()
main_widget()
plugins()
review_controller()
scheduler()
statistics_pages()
stopwatch()

Previous topic

Libmnemosyne overview

Next topic

ComponentManager

This Page

Quick search