File: __init__.py

package info (click to toggle)
python-npe2 0.7.8-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 828 kB
  • sloc: python: 7,088; makefile: 19
file content (97 lines) | stat: -rw-r--r-- 2,329 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
from functools import partial

import numpy as np
from magicgui import magic_factory
from napari_plugin_engine import napari_hook_implementation


class MyWidget: ...


def some_function(x: int): ...


def gen_data(): ...


@napari_hook_implementation
def napari_get_reader(path): ...


@napari_hook_implementation(specname="napari_get_reader")
def napari_other_reader(path): ...


@napari_hook_implementation
def napari_write_image(path, data, meta): ...


@napari_hook_implementation
def napari_write_labels(path, data, meta): ...


@napari_hook_implementation(specname="napari_write_labels")
def napari_other_write_labels(path, data, meta): ...


@napari_hook_implementation
def napari_provide_sample_data():
    return {
        "random data": gen_data,
        "local data": partial(np.ones, (4, 4)),
        "random image": "https://picsum.photos/1024",
        "sample_key": {
            "display_name": "Some Random Data (512 x 512)",
            "data": gen_data,
        },
        "local_ones": {
            "display_name": "Some local ones",
            "data": partial(np.ones, (4, 4)),
        },
    }


@napari_hook_implementation
def napari_experimental_provide_theme():
    return {
        "super_dark": {
            "name": "super_dark",
            "background": "rgb(12, 12, 12)",
            "foreground": "rgb(65, 72, 81)",
            "primary": "rgb(90, 98, 108)",
            "secondary": "rgb(134, 142, 147)",
            "highlight": "rgb(106, 115, 128)",
            "text": "rgb(240, 241, 242)",
            "icon": "rgb(209, 210, 212)",
            "warning": "rgb(153, 18, 31)",
            "current": "rgb(0, 122, 204)",
            "syntax_style": "native",
            "console": "rgb(0, 0, 0)",
            "canvas": "black",
        },
        "pretty_light": {
            "background": "rgb(192, 223, 139)",
        },
    }


factory = magic_factory(some_function)


@napari_hook_implementation
def napari_experimental_provide_dock_widget():
    @magic_factory
    def local_widget(y: str): ...

    return [
        MyWidget,
        (factory, {"name": "My Other Widget"}),
        (local_widget, {"name": "Local Widget"}),
    ]


@napari_hook_implementation
def napari_experimental_provide_function():
    def local_function(x: int): ...

    return [some_function, local_function]