Skip to content

gui

ExperimentGui

Bases: BaseTierGui[Experiment]

Source code in cassini/ext/ipygui/gui.py
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
class ExperimentGui(BaseTierGui[Experiment]):
    def new_dataset(self) -> DOMWidget:
        """
        A handy widget for creating new `DataSets`.
        """
        samples = list(self.tier)
        option_map = {sample.name: sample for sample in samples}

        selection = SelectMultiple(options=option_map.keys(), description="Auto Add")

        def create(form, name, auto_add):
            with form.status:
                self.tier.setup_technique(name)
                if auto_add:
                    for sample in (option_map[name] for name in auto_add):
                        o = sample[name]
                        o.setup_files()
                        display(widgetify_html(o._repr_html_()))

        form = InputSequence(
            create, Text(description="Name:", placeholder="e.g. XRD"), selection
        )

        return form.as_widget()

    def _get_header_components(self) -> Dict[str, DOMWidget]:
        components = super()._get_header_components()
        components["New Data"] = self.new_dataset
        return components

new_dataset

new_dataset()

A handy widget for creating new DataSets.

Source code in cassini/ext/ipygui/gui.py
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
def new_dataset(self) -> DOMWidget:
    """
    A handy widget for creating new `DataSets`.
    """
    samples = list(self.tier)
    option_map = {sample.name: sample for sample in samples}

    selection = SelectMultiple(options=option_map.keys(), description="Auto Add")

    def create(form, name, auto_add):
        with form.status:
            self.tier.setup_technique(name)
            if auto_add:
                for sample in (option_map[name] for name in auto_add):
                    o = sample[name]
                    o.setup_files()
                    display(widgetify_html(o._repr_html_()))

    form = InputSequence(
        create, Text(description="Name:", placeholder="e.g. XRD"), selection
    )

    return form.as_widget()