a63ee461581c98811cc7b82441ce8b3e9ac13a3c
[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 #    'selection',
35 #    'welcome',
36     ]
37 """List of panel modules.  TODO: autodiscovery
38 """
39
40 class Panel (object):
41     """Base class for Hooke GUI panels.
42     
43     :attr:`name` identifies the request type and should match the
44     module name.
45     """
46     def __init__(self, name=None, callbacks=None, **kwargs):
47         super(Panel, self).__init__(**kwargs)
48         self.name = name
49         self.managed_name = name.capitalize()
50         self._hooke_frame = kwargs.get('parent', None)
51         if callbacks == None:
52             callbacks = {}
53         self._callbacks = callbacks
54
55
56 PANELS = construct_odict(
57     this_modname=__name__,
58     submodnames=PANEL_MODULES,
59     class_selector=IsSubclass(Panel, blacklist=[Panel]),
60     instantiate=False)
61 """:class:`hooke.compat.odict.odict` of :class:`Panel`
62 instances keyed by `.name`.
63 """