source: orange/Orange/OrangeCanvas/registry/__init__.py @ 11098:b743937fe90a

Revision 11098:b743937fe90a, 1.6 KB checked in by Ales Erjavec <ales.erjavec@…>, 19 months ago (diff)

Added new widget/category description classes and new widget discovery.

This includes a Qt item model interface for the registry.

Line 
1"""
2===============
3Widget Registry
4===============
5
6A registry (and discovery) of available widgets.
7
8"""
9
10import logging
11
12# Color names that can be used in widget/category descriptions
13# as background color.
14NAMED_COLORS = \
15    {"light-orange": "#FFD39F",
16     "orange": "#FFA840",
17     "light-red": "#FFB7B1",
18     "red": "#FF7063",
19     "light-pink": "#FAC1D9",
20     "pink": "#F584B4",
21     "light-purple": "#E5BBFB",
22     "purple": "#CB77F7",
23     "light-blue": "#CAE1FC",
24     "blue": "#95C3F9",
25     "light-turquoise": "#C3F3F3",
26     "turquoise": "#87E8E8",
27     "light-green": "#ACE3CE",
28     "green": "#5AC79E",
29     "light-grass": "#DFECB0",
30     "grass": "#C0D962",
31     "light-yellow": "#F7F5A7",
32     "yellow": "#F0EC4F",
33     }
34
35
36from .description import (
37    WidgetDescription, CategoryDescription,
38    InputSignal, OutputSignal
39)
40
41from .base import WidgetRegistry, VERSION_HEX
42
43log = logging.getLogger(__name__)
44
45
46__GLOBAL_REGISTRY = None
47
48
49def global_registry():
50    """Return a global WidgetRegistry instance.
51    """
52    global __GLOBAL_REGISTRY
53    # TODO: lock
54    if __GLOBAL_REGISTRY is None:
55        log.debug("'global_registry()' - running widget discovery.")
56        from . import discovery
57        reg = WidgetRegistry()
58        disc = discovery.WidgetDiscovery(reg)
59        disc.run()
60        log.info("'global_registry()' discovery finished.")
61        __GLOBAL_REGISTRY = reg
62
63    return __GLOBAL_REGISTRY
64
65
66def set_global_registry(registry):
67    global __GLOBAL_REGISTRY
68    log.debug("'set_global_registry()' - setting registry.")
69    __GLOBAL_REGISTRY = registry
Note: See TracBrowser for help on using the repository browser.