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