~emihalac/mnemosyne-proj/mnemosyne-proj

« back to all changes in this revision

Viewing changes to mnemosyne/mnemosyne/libmnemosyne/component.py

  • Committer: Peter Bienstman
  • Date: 2017-03-21 18:58:09 UTC
  • Revision ID: peter.bienstman@ugent.be-20170321185809-4pd9slxfin1y1l8t
Bug fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
        super().__init__(**kwds)  # For parent classes other than 'Object'.   
52
52
        self.component_manager = component_manager
53
53
        self.gui_components = []
 
54
        self.instantiated_gui_components = []
54
55
 
55
56
    def activate(self):
56
57
 
57
58
        """Initialisation code called when the component is about to do actual
58
59
        work, and which can't happen in the constructor, e.g. because
59
60
        components on which it relies have not yet been registered.
 
61
        
 
62
        GUI classes are only instantiated when activated, since that can take
 
63
        a lot of time on mobile clients.
60
64
 
61
65
        """
62
66
 
63
 
        pass
 
67
        for component in self.gui_components:
 
68
            component = component(component_manager=self.component_manager) 
 
69
            self.component_manager.register(component)
 
70
            component.activate()  
 
71
            self.instantiated_gui_components.append(component)
64
72
 
65
73
    def deactivate(self):
66
 
        pass
 
74
        for component in self.instantiated_gui_components:
 
75
            component.deactivate()
 
76
            self.component_manager.unregister(component)            
 
77
        self.instantiated_gui_components = []
67
78
 
68
79
    # Convenience functions, for easier access to all of the context of
69
80
    # libmnemosyne from within a component.