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