Ran update_copyright.py
[hooke.git] / hooke / ui / gui / panel / __init__.py
1 # Copyright (C) 2010 Massimo Sandal <devicerandom@gmail.com>
2 #                    W. Trevor King <wking@drexel.edu>
3 #
4 # This file is part of Hooke.
5 #
6 # Hooke is free software: you can redistribute it and/or modify it
7 # under the terms of the GNU Lesser General Public License as
8 # published by the Free Software Foundation, either version 3 of the
9 # License, or (at your option) any later version.
10 #
11 # Hooke is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
14 # Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with Hooke.  If not, see
18 # <http://www.gnu.org/licenses/>.
19
20 """The `panel` module provides optional submodules that add GUI panels.
21 """
22
23 from ....util.pluggable import IsSubclass, construct_odict
24
25
26 PANEL_MODULES = [
27     'commands',
28     'note',
29 #    'notebook',
30     'output',
31     'playlist',
32     'plot',
33     'propertyeditor',
34 #    'results',
35 #    'selection',
36 #    'welcome',
37     ]
38 """List of panel modules.  TODO: autodiscovery
39 """
40
41 class Panel (object):
42     """Base class for Hooke GUI panels.
43     
44     :attr:`name` identifies the request type and should match the
45     module name.
46     """
47     def __init__(self, name=None, callbacks=None, **kwargs):
48         super(Panel, self).__init__(**kwargs)
49         self.name = name
50         self.managed_name = name.capitalize()
51         self._hooke_frame = kwargs.get('parent', None)
52         if callbacks == None:
53             callbacks = {}
54         self._callbacks = callbacks
55
56
57 PANELS = construct_odict(
58     this_modname=__name__,
59     submodnames=PANEL_MODULES,
60     class_selector=IsSubclass(Panel, blacklist=[Panel]),
61     instantiate=False)
62 """:class:`hooke.compat.odict.odict` of :class:`Panel`
63 instances keyed by `.name`.
64 """