Пример #1
0
    def make_form(self, css_classes):
        iocont =  widgets.ContainerWidget()
        css_classes[iocont] = ('iobject-container')
        add_child(iocont, widgets.HTMLWidget(value = "<h3>%s</h3>"%self.name))
        for inp in self.free_inputs:
            #We have to filter none kw...
            allkw = dict(description = inp.name, value = inp.value,
                       default = inp.default)
            kw = {key:value for (key,value) in allkw.items()
                    if value is not None}
            w = widgets.TextWidget(**kw)
            inp.widget = w
            w.traits()['value'].allow_none = True
            traitlets.link((inp,'value'),(w,'value'))

            def set_exec(_w):
                self.executed = False
            w.on_trait_change(set_exec, name = 'value')
            add_child(iocont,w)

        for out in self.free_outputs:
            w = widgets.HTMLWidget()
            out.widget = w
            add_child(iocont,w)
            w.traits()['value'].allow_none = True
            traitlets.link((out,'value'),(w,'value'))

        button = widgets.ButtonWidget(description = "Execute %s" % self.name)
        def _run(b):
            self.executed = False
            self.run_sync()
        button.on_click(_run)
        add_child(iocont, button)

        self.widget = iocont
        self.widget.button = button
        self.has_widget = True
        self._toggle_executed()
        return iocont
Пример #2
0
 def make_control(self):
     control_container = widgets.ContainerWidget()
     run_all_btn = widgets.ButtonWidget(description = "Run all")
     def _ra(btn):
         result = self.run_all()
         display(result)
     run_all_btn.on_click(_ra)
     add_child(control_container, widgets.HTMLWidget(
                 value="<h2>%s</h2>"%self.name))
     add_child(control_container, run_all_btn)
     css_classes = {control_container: 'control-container'}
     for node in self.sorted_iterate():
         add_child(control_container, node.make_form(css_classes))
     display(control_container)
     for (widget, klass) in css_classes.items():
         if isinstance(widget, widgets.ContainerWidget):
             widget.remove_class("vbox")
         widget.add_class(klass)