hooke.ui.gui was getting complicated, so I stripped it down for a moment.
[hooke.git] / hooke / ui / gui / handler / __init__.py
1 # Copyright\r
2 \r
3 from ....util.pluggable import IsSubclass, construct_graph\r
4 \r
5 \r
6 HANDLER_MODULES = [\r
7     'boolean',\r
8     'float',\r
9 #    'int'\r
10 #    'point',\r
11     'selection',\r
12     'string'\r
13     ]\r
14 """List of handler modules.  TODO: autodiscovery\r
15 """\r
16 \r
17 class Handler (object):\r
18     """Base class for :class:`~hooke.interaction.Request` handlers.\r
19     \r
20     :attr:`name` identifies the request type and should match the\r
21     module name.\r
22     """\r
23     def __init__(self, name):\r
24         self.name = name\r
25 \r
26     def run(self, hooke_frame, msg):\r
27         raise NotImplemented\r
28 \r
29     def _cancel(self, *args, **kwargs):\r
30         # TODO: somehow abort the running command\r
31 \r
32 \r
33 HANDLERS = construct_odict(\r
34     this_modname=__name__,\r
35     submodnames=USER_INTERFACE_MODULES,\r
36     class_selector=IsSubclass(UserInterface, blacklist=[UserInterface]))\r
37 """:class:`hooke.compat.odict.odict` of :class:`Handler`\r
38 instances keyed by `.name`.\r
39 """\r