def unit_panel(self):
        # create spectrum controls.  NOTE: should only be called once.
        specunit = Dropdown(description="Specunit",values=self.model.SPECUNITS.values())
        link((self.model,"spec_unit"),(specunit,"value"))

        varunit = Dropdown(description="Varunit",values=self.model.VARUNITS.values())
        link((self.model,"var_unit"),(varunit,"value"))

        iunit = Text(description="I Unit",values=self.model.iunit)
        link((self.model,"iunit"),(iunit,"value"))

        normunit = Dropdown(description="Normunit",values=self.model.NORMUNITS.values())
        link((self.model,"norm_unit"),(normunit,"value"))
	
	eggs_dropdown =Dropdown(description="My eggs", values=self.model.EGGS)
	link((self.model,"eggs"),(eggs_dropdown,"value"))

        return ControlPanel(title="Units",
                            children= [
                                normunit,
                                specunit,
                                varunit,
                                iunit,
	                        eggs_dropdown
                            ])
Beispiel #2
0
    def __init__(self, *args, **kwd):
        super(ToggleGo, self).__init__(*args, **kwd)
        self._go_container = widgets.HBox(visible=self.toggle.value)
        self._go_button = widgets.Button(description="Lock settings and Go!",
                                         disabled=True, visible=False)
        self._change_settings = widgets.Button(description="Unlock settings",
                                               disabled=True,
                                               visible=False)
        self._go_container.children = [self._go_button, self._change_settings]
        self._progress_container = widgets.Box()
        self._progress_bar = widgets.FloatProgress(min=0, max=1.0,
                                                   step=0.01, value=0.0,
                                                   visible=False)
        self._progress_container.children = [self._progress_bar]
        # we want the go button to be in a container below the
        #  ToggleContainer's container -- actually, no, want these
        # buttons controlled by toggle...wait, no, I really do want that, but
        # I also want to tie their visibility to the toggle.
        kids = list(self.children)
        kids.append(self._go_container)
        kids.append(self._progress_container)
        self.children = kids

        # Tie visibility of go button to toggle state. Needs to be separate
        # from the container.
        link((self._go_container, str('visible')), (self.toggle, str('value')))

        self._go_button.on_click(self.go())
        self._change_settings.on_click(self.unlock())

        # Tie self._state_monitor to both go button and color of toggle button
        self._state_monitor.on_trait_change(self.state_change_handler(),
                                            str('value'))
        self._state_monitor.on_trait_change(set_color_for(self), str('value'))
 def plot_plugin_panel(self):
     plugin1= Checkbox(description='plugin1')
     plugin2= Checkbox(description='plugin2')
     plugin3= Checkbox(description='plugin3')
     cp = ControlPanel(title='Choose Plot Plugins',children=[plugin1,plugin2,plugin3])
     link((self.more,"value"),(cp,"visible"))
     return cp
Beispiel #4
0
    def __init__(self, **kwargs):
        super(self.__class__, self).__init__(**kwargs)

        colours = [
            "black", "red", "orange", "yellow", "green", "blue", "magenta",
            "cyan"
        ]

        # allow toggling of SVG draw mode
        draw_toggle_values = [
            "select", "rect", "circle", "ellipse", "line", "path"
        ]
        self.draw_toggle = widgets.ToggleButtonsWidget(
            values=draw_toggle_values, description="Choose drawing tool:")

        # set up the stroke controls
        self.stroke_picker = widgets.DropdownWidget(
            values=colours, description="Stroke colour:")
        self.stroke_width_slider = widgets.FloatSliderWidget(
            min=0, max=20, value=3, description="Stroke width:")

        self.stroke_container = HorizontalContainerWidget()
        self.stroke_container.children = [
            self.stroke_picker, self.stroke_width_slider
        ]

        # set up the fill controls
        self.fill_picker = widgets.DropdownWidget(values=["none"] + colours,
                                                  description="Fill colour:")
        self.fill_opacity_slider = widgets.FloatSliderWidget(
            min=0, max=1, value=0.5, description="Fill opacity:")

        self.fill_container = HorizontalContainerWidget()
        self.fill_container.children = [
            self.fill_picker, self.fill_opacity_slider
        ]

        # the main SVG
        self.svg = SVGWidget()

        # border the SVG
        self.svg.set_css('border', '1px solid black')

        # link the control widgets to the SVG control variables
        self.mode_link = traitlets.link((self.draw_toggle, 'value'),
                                        (self.svg, 'mode'))
        self.stroke_link = traitlets.link((self.stroke_picker, 'value'),
                                          (self.svg, 'stroke'))
        self.stroke_width_link = traitlets.link(
            (self.stroke_width_slider, 'value'), (self.svg, 'stroke_width'))
        self.fill_link = traitlets.link((self.fill_picker, 'value'),
                                        (self.svg, 'fill'))
        self.fill_opacity_link = traitlets.link(
            (self.fill_opacity_slider, 'value'), (self.svg, 'fill_opacity'))

        # define the main container's children
        self.children = [
            self.draw_toggle, self.stroke_container, self.fill_container,
            self.svg
        ]
Beispiel #5
0
 def user_function_panel(self):
     f = Text(description="Function, Args:")
     link((self.model, "user_f"), (f, "value"))
     fapp = Button(description="Apply")
     fapp.on_click(lambda x: self.model.apply_userf(name='Apply clicked'))
     cp2 = ControlPanel(title='User Defined Function', children=[f, fapp])
     link((self.more, "value"), (cp2, "visible"))
     return cp2
 def user_function_panel(self):
     f = Text(description="Function, Args:")
     link((self.model,"user_f"),(f,"value"))
     fapp = Button(description = "Apply")
     fapp.on_click(lambda x: self.model.apply_userf(name='Apply clicked'))
     cp2 = ControlPanel(title='User Defined Function',children=[f,fapp])
     link((self.more,"value"),(cp2,"visible"))
     return cp2
Beispiel #7
0
    def __init__(self, *args, **kwargs):
        super(AutoTangle, self).__init__(*args, **kwargs)

        for key, widget_traitlet in self._links:
            link((self, key), widget_traitlet)

        for key, fn_subscribed in self._derived.items():
            self._subscribe(key, fn_subscribed)
Beispiel #8
0
 def plot_plugin_panel(self):
     plugin1 = Checkbox(description='plugin1')
     plugin2 = Checkbox(description='plugin2')
     plugin3 = Checkbox(description='plugin3')
     cp = ControlPanel(title='Choose Plot Plugins',
                       children=[plugin1, plugin2, plugin3])
     link((self.more, "value"), (cp, "visible"))
     return cp
Beispiel #9
0
    def __init__(self, *args, **kwargs):
        super(AutoTangle, self).__init__(*args, **kwargs)

        for key, widget_traitlet in self._links:
            link((self, key), widget_traitlet)

        for key, fn_subscribed in self._derived.items():
            self._subscribe(key, fn_subscribed)
Beispiel #10
0
    def __init__(self, **kwargs):
        super(LinkedConfig, self).__init__(**kwargs)

        # link the trait values between the parent and the config
        for trait in self.traits(config=True):
            link((self, trait), (self.parent, trait))

        # link the parent's config with our config
        link((self.parent, 'config'), (self, 'config'))
Beispiel #11
0
    def __init__(self, **kwargs):
        super(LinkedConfig, self).__init__(**kwargs)

        # link the trait values between the parent and the config
        for trait in self.traits(config=True):
            link((self, trait), (self.parent, trait))

        # link the parent's config with our config
        link((self.parent, 'config'), (self, 'config'))
Beispiel #12
0
def iview(self, width = 400):
    f = lambda rows_start, rows_end,cols: display(self[list(cols)].iloc[rows_start:rows_end])
    rs = IntSlider(min=0, max=self.shape[0], width=width)
    re = IntSlider(min=0, max=self.shape[0], width= width)
    link((re, 'min'), (rs, 'value'))
    interact(f,
             cols=SelectMultiple(options=self.columns.tolist()),
             rows_start=rs,
             rows_end=re, width=width)
Beispiel #13
0
    def naeem_panel(self):

        plott = Dropdown(description="Corr Plot",
                         values=[
                             'sync', 'async', 'phase', 'modulous',
                             'sync_codist', 'async_codist'
                         ])
        link((self.model, "plottype"), (plott, "value"))

        plot_3d = Dropdown(description="Kind",
                           values=['corr2d', 'corr3d', 'contour3d'])
        link((self.model, "plot3d"), (plot_3d, "value"))

        scale_a = FloatSlider(description="Scale Start")

        scale_b = FloatSlider(description="Scale End")

        scalecheck = Checkbox(description="Scalling")
        link((self.model, "scalebox"), (scalecheck, "value"))

        cfill = Checkbox(description="Fill")
        link((self.model, "fill"), (cfill, "value"))

        return ControlPanel(
            title="NAEEM KHAN",
            children=[plott, plot_3d, scalecheck, scale_a, scale_b, cfill])
Beispiel #14
0
    def __init__(self, coordinate_frames, topology, width=500, height=500):
        '''Display a trajectory in the IPython notebook.

        :param list coordinate_frames: A list containing the positions of the atoms (as np.ndarray) for each frame.
        :param dict topology: A dictionary specifying the topology 

        ..seealso:: :class:`chemview.MolecularViewer`

        '''
        self.coordinate_frames = coordinate_frames
        super(TrajectoryViewer, self).__init__(coordinate_frames[0], topology)

        self.controls = TrajectoryControls(len(coordinate_frames))
        link((self, 'frame'), (self.controls, 'frame'))
    def naeem_panel(self):
	
	plott= Dropdown(description="Corr Plot", values=['sync','async','phase','modulous','sync_codist','async_codist'])
	link((self.model,"plottype"), (plott, "value"))
	
	plot_3d= Dropdown(description="Kind", values=['corr2d','corr3d', 'contour3d'])
	link((self.model,"plot3d"), (plot_3d,"value"))
	
	scale_a= FloatSlider(description="Scale Start")
	
	scale_b= FloatSlider(description="Scale End")
	
	scalecheck = Checkbox(description="Scalling")
	link((self.model,"scalebox"),(scalecheck,"value"))
	
	cfill = Checkbox(description="Fill")
	link((self.model, "fill"), (cfill, "value"))	
	
	
        return ControlPanel(title="NAEEM KHAN", 
                            children=[
                                plott,
	                        plot_3d,
	                        scalecheck,
	                        scale_a,
	                        scale_b,
	                        cfill
	                        ]
                            )	
    def __init__(self, model=None, model_config=None, *args, **kwargs):
	# RUN HTML
        self.model = model or Spectrogram(**(model_config or {}))  #Need to access spectrogram if defaulting...
        # Create alert widget (refactor into its own function?)
        alert = Alert(description = "Alert or something")
        link((self.model, "message"), (alert, "value"))

        # Create a GUI
        kwargs["orientation"] = 'horizontal'
        kwargs["children"] = [HBox([
                                    VBox([self.INOUT_panel(), self.model, alert]),
                                    VBox([self.plot_panel(),self.slicing_panel(),self.unit_panel()]),
                                    ])
                              ]
        super(SpectraGui, self).__init__(*args, **kwargs)
        self._dom_classes += ("spectroscopy row",)
Beispiel #17
0
    def __init__(self, coordinate_frames, topology, width=500, height=500):
        '''Display a trajectory in the IPython notebook.

        :param list coordinate_frames: A list containing the positions of the atoms (as np.ndarray) for each frame.
        :param dict topology: A dictionary specifying the topology 

        .. seealso:: :class:`MolecularViewer`

        '''
        self.coordinate_frames = coordinate_frames
        super(TrajectoryViewer, self).__init__(coordinate_frames[0],
                                               topology,
                                               width=width,
                                               height=height)

        self.controls = TrajectoryControls(len(coordinate_frames))
        link((self, 'frame'), (self.controls, 'frame'))
Beispiel #18
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
Beispiel #19
0
 def interact(self, **kwargs):
     c = []
     for name, abbrev in kwargs.items():
         default = getattr(self, name)
         widget = _widget_from_abbrev(abbrev, default)
         if not widget.description:
             widget.description = name
         widget.link = link((widget,'value'),(self,name))
         c.append(widget)
     cont = widgets.ContainerWidget(children=c)
     return cont
Beispiel #20
0
    def __init__(self, **kwargs):
        super(self.__class__, self).__init__(**kwargs)

        colours = ["black","red","orange","yellow","green","blue","magenta","cyan"]
        
        # allow toggling of SVG draw mode                                                                             
        draw_toggle_values = ["select","rect","circle","ellipse","line","path"]
        self.draw_toggle = widgets.ToggleButtonsWidget(values = draw_toggle_values,description="Choose drawing tool:")

        # set up the stroke controls
        self.stroke_picker = widgets.DropdownWidget(values = colours,description="Stroke colour:")
        self.stroke_width_slider = widgets.FloatSliderWidget(min=0,max=20,value=3,description="Stroke width:")
        
        self.stroke_container = HorizontalContainerWidget()
        self.stroke_container.children = [self.stroke_picker,self.stroke_width_slider]
        
        # set up the fill controls
        self.fill_picker = widgets.DropdownWidget(values = ["none"] + colours,description="Fill colour:")
        self.fill_opacity_slider = widgets.FloatSliderWidget(min=0,max=1,value=0.5,description="Fill opacity:")
        
        self.fill_container = HorizontalContainerWidget()
        self.fill_container.children = [self.fill_picker,self.fill_opacity_slider]
        
        # the main SVG
        self.svg = SVGWidget()
        
        # border the SVG
        self.svg.set_css('border', '1px solid black') 


        # link the control widgets to the SVG control variables                                                                       
        self.mode_link = traitlets.link((self.draw_toggle, 'value'), (self.svg, 'mode'))
        self.stroke_link = traitlets.link((self.stroke_picker, 'value'), (self.svg, 'stroke'))
        self.stroke_width_link = traitlets.link((self.stroke_width_slider, 'value'), (self.svg, 'stroke_width'))
        self.fill_link = traitlets.link((self.fill_picker, 'value'), (self.svg, 'fill'))
        self.fill_opacity_link = traitlets.link((self.fill_opacity_slider, 'value'), (self.svg, 'fill_opacity'))
        
        # define the main container's children
        self.children = [self.draw_toggle,self.stroke_container,self.fill_container,self.svg]
Beispiel #21
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
Beispiel #22
0
    def unit_panel(self):
        # create spectrum controls.  NOTE: should only be called once.
        specunit = Dropdown(description="Specunit",
                            values=self.model.SPECUNITS.values())
        link((self.model, "spec_unit"), (specunit, "value"))

        varunit = Dropdown(description="Varunit",
                           values=self.model.VARUNITS.values())
        link((self.model, "var_unit"), (varunit, "value"))

        iunit = Text(description="I Unit", values=self.model.iunit)
        link((self.model, "iunit"), (iunit, "value"))

        normunit = Dropdown(description="Normunit",
                            values=self.model.NORMUNITS.values())
        link((self.model, "norm_unit"), (normunit, "value"))

        eggs_dropdown = Dropdown(description="My eggs", values=self.model.EGGS)
        link((self.model, "eggs"), (eggs_dropdown, "value"))

        return ControlPanel(
            title="Units",
            children=[normunit, specunit, varunit, iunit, eggs_dropdown])
Beispiel #23
0
    def __init__(self, model=None, model_config=None, *args, **kwargs):
        # RUN HTML
        self.model = model or Spectrogram(
            **(model_config
               or {}))  #Need to access spectrogram if defaulting...
        # Create alert widget (refactor into its own function?)
        alert = Alert(description="Alert or something")
        link((self.model, "message"), (alert, "value"))

        # Create a GUI
        kwargs["orientation"] = 'horizontal'
        kwargs["children"] = [
            HBox([
                VBox([self.INOUT_panel(), self.model, alert]),
                VBox([
                    self.plot_panel(),
                    self.slicing_panel(),
                    self.unit_panel()
                ]),
            ])
        ]
        super(SpectraGui, self).__init__(*args, **kwargs)
        self._dom_classes += ("spectroscopy row", )
Beispiel #24
0
 def test_validate_args(self):
     class A(HasTraits):
         value = Int()
     class B(HasTraits):
         count = Int()
     a = A(value=9)
     b = B(count=8)
     b.value = 5
     
     with self.assertRaises(TypeError):
         link((a, 'value'))
     with self.assertRaises(TypeError):
         link((a, 'value', 'count'), (b, 'count'))
     with self.assertRaises(TypeError):
         link((a, 'value'), (b, 'value'))
     with self.assertRaises(TypeError):
         link((a, 'traits'), (b, 'count'))
Beispiel #25
0
    def test_unlink(self):
        """Verify two linked traitlets can be unlinked."""

        # Create two simple classes with Int traitlets.
        class A(HasTraits):
            value = Int()
        a = A(value=9)
        b = A(value=8)

        # Connect the two classes.
        c = link((a, 'value'), (b, 'value'))
        a.value = 4
        c.unlink()

        # Change one of the values to make sure they don't stay in sync.
        a.value = 5
        self.assertNotEqual(a.value, b.value)
Beispiel #26
0
    def test_validate_args(self):
        class A(HasTraits):
            value = Int()

        class B(HasTraits):
            count = Int()

        a = A(value=9)
        b = B(count=8)
        b.value = 5

        with self.assertRaises(TypeError):
            link((a, 'value'))
        with self.assertRaises(TypeError):
            link((a, 'value', 'count'), (b, 'count'))
        with self.assertRaises(TypeError):
            link((a, 'value'), (b, 'value'))
        with self.assertRaises(TypeError):
            link((a, 'traits'), (b, 'count'))
Beispiel #27
0
    def test_validate_args(self):
        class A(HasTraits):
            value = Int()

        class B(HasTraits):
            count = Int()

        a = A(value=9)
        b = B(count=8)
        b.value = 5

        with self.assertRaises(TypeError):
            link((a, "value"))
        with self.assertRaises(TypeError):
            link((a, "value", "count"), (b, "count"))
        with self.assertRaises(TypeError):
            link((a, "value"), (b, "value"))
        with self.assertRaises(TypeError):
            link((a, "traits"), (b, "count"))
    def test_callbacks(self):
        """Verify two linked traitlets have their callbacks called once."""

        # Create two simple classes with Int traitlets.
        class A(HasTraits):
            value = Int()

        class B(HasTraits):
            count = Int()

        a = A(value=9)
        b = B(count=8)

        # Register callbacks that count.
        callback_count = []

        def a_callback(name, old, new):
            callback_count.append("a")

        a.on_trait_change(a_callback, "value")

        def b_callback(name, old, new):
            callback_count.append("b")

        b.on_trait_change(b_callback, "count")

        # Connect the two classes.
        c = link((a, "value"), (b, "count"))

        # Make sure b's count was set to a's value once.
        self.assertEqual("".join(callback_count), "b")
        del callback_count[:]

        # Make sure a's value was set to b's count once.
        b.count = 5
        self.assertEqual("".join(callback_count), "ba")
        del callback_count[:]

        # Make sure b's count was set to a's value once.
        a.value = 4
        self.assertEqual("".join(callback_count), "ab")
        del callback_count[:]
Beispiel #29
0
    def test_callbacks(self):
        """Verify two linked traitlets have their callbacks called once."""

        # Create two simple classes with Int traitlets.
        class A(HasTraits):
            value = Int()

        class B(HasTraits):
            count = Int()

        a = A(value=9)
        b = B(count=8)

        # Register callbacks that count.
        callback_count = []

        def a_callback(name, old, new):
            callback_count.append('a')

        a.on_trait_change(a_callback, 'value')

        def b_callback(name, old, new):
            callback_count.append('b')

        b.on_trait_change(b_callback, 'count')

        # Connect the two classes.
        c = link((a, 'value'), (b, 'count'))

        # Make sure b's count was set to a's value once.
        self.assertEqual(''.join(callback_count), 'b')
        del callback_count[:]

        # Make sure a's value was set to b's count once.
        b.count = 5
        self.assertEqual(''.join(callback_count), 'ba')
        del callback_count[:]

        # Make sure b's count was set to a's value once.
        a.value = 4
        self.assertEqual(''.join(callback_count), 'ab')
        del callback_count[:]
Beispiel #30
0
    def test_connect_same(self):
        """Verify two traitlets of the same type can be linked together using link."""

        # Create two simple classes with Int traitlets.
        class A(HasTraits):
            value = Int()
        a = A(value=9)
        b = A(value=8)

        # Conenct the two classes.
        c = link((a, 'value'), (b, 'value'))

        # Make sure the values are the same at the point of linking.
        self.assertEqual(a.value, b.value)

        # Change one of the values to make sure they stay in sync.
        a.value = 5
        self.assertEqual(a.value, b.value)
        b.value = 6
        self.assertEqual(a.value, b.value)
Beispiel #31
0
    def test_link_different(self):
        """Verify two traitlets of different types can be linked together using link."""

        # Create two simple classes with Int traitlets.
        class A(HasTraits):
            value = Int()
        class B(HasTraits):
            count = Int()
        a = A(value=9)
        b = B(count=8)

        # Conenct the two classes.
        c = link((a, 'value'), (b, 'count'))

        # Make sure the values are the same at the point of linking.
        self.assertEqual(a.value, b.count)

        # Change one of the values to make sure they stay in sync.
        a.value = 5
        self.assertEqual(a.value, b.count)
        b.count = 4
        self.assertEqual(a.value, b.count)
    def slicing_panel(self):
        """ create spectrum controls.  NOTE: should only be called once."""

        model = self.model #For readability

        # ALL WIDGETS ARE CAPITALIZED. 
        #AXIS = RadioButtons(values=[0,1],description="Axis")
        #link((model, "slice_axis"), (AXIS, "value"))

        SPECSTART = FloatSlider(description="Spec Start",
                                min=model.specslice_position_start) #Will not try to update

        link((model,"specslice_position_start"),(SPECSTART,"value"))
        link((model,"specstep"),(SPECSTART,"step"))
        link((model,"specslider_start"),(SPECSTART,"min")) # Start end values (IE slider_min / slider_max)
        link((model,"specslider_end"),(SPECSTART,"max"))

        SPECEND = FloatSlider(description="Spec End",
                              max=model.specslice_position_end) # Will not try to update

        link((model,"specslice_position_end"),(SPECEND,"value"))
        link((model,"specstep"),(SPECEND,"step"))
        link((model,"specslider_start"),(SPECEND,"min"))
        link((model,"specslider_end"),(SPECEND,"max"))

        # SPACING WIDGET
        SPECSPACING = IntText(description="Spec Sample by",value=1)
        link((model,"specspacing"),(SPECSPACING,"value"))

        TIMESTART = FloatSlider(description="Var Start",
                                min=model.timeslice_position_start)

        link((model,"timeslice_position_start"),(TIMESTART,"value"))
        link((model,"timestep"),(TIMESTART,"step"))
        link((model,"timeslider_start"),(TIMESTART,"min"))
        link((model,"timeslider_end"),(TIMESTART,"max"))

        TIMEEND = FloatSlider(description="Var End",
                              max=model.timeslice_position_end)
        link((model,"timeslice_position_end"),(TIMEEND,"value"))
        link((model,"timestep"),(TIMEEND,"step"))
        link((model,"timeslider_start"),(TIMEEND,"min"))
        link((model,"timeslider_end"),(TIMEEND,"max"))

        TIMESPACING = IntText(description="Var Sample by",value=1)
        link((model,"timespacing"),(TIMESPACING,"value"))

        speccheck = Checkbox(description="Spectral Axis")
        link((model,"specbox"),(speccheck,"value"))
        SPECRANGED = VBox([SPECSTART,SPECEND,SPECSPACING])
        link((model,"specbox"),(SPECRANGED,"visible"))
        
        timecheck = Checkbox(description="Variation Axis")
        link((model,"timebox"),(timecheck,"value"))
        TIMERANGED = VBox([TIMESTART, TIMEEND, TIMESPACING])
        link((model,"timebox"),(TIMERANGED,"visible"))

        return ControlPanel(title="Slicing/Sampling",
                            children=[
                                HBox([speccheck, timecheck]),
                                SPECRANGED,
                                TIMERANGED
                            ]
                            )
    def _update(self, state="default"):
        for obj_name in self._object_list:
            ##apply attributes
            default_style = {}
            if obj_name in self._display_list:
                default_style = self._default_display_style
            elif obj_name in self._io_list:
                default_style = self._default_io_style

            default_attributes = {}
            if "default" in self._attributes:
                if obj_name in self._attributes["default"]:
                    default_attributes = self._attributes["default"][obj_name]

            state_attributes = {}
            if state in self._attributes:
                if obj_name in self._attributes[state]:
                    state_attributes = self._attributes[state][obj_name]

            attributes = default_style.copy()
            attributes.update(default_attributes)
            attributes.update(state_attributes)

            if not "visible" in attributes:
                attributes["visible"] = False

            self.set_attributes(obj_name, **attributes)

        ##apply links
        for link_name in self._link_object:  # clear link objects
            self._link_object[link_name].unlink()
        self._link_objects = {}

        default_links = {}
        if "default" in self._links:
            default_links = self._links["default"]

        state_links = {}
        if state in self._links:
            state_links = self._links[state]

        links_dict = default_links.copy()
        links_dict.update(state_links)

        for link_name in links_dict:
            directional, links_list = links_dict[link_name]
            links = []
            for link in links_list:
                links.append((self._object_list[link[0]], link[1]))
            if directional:
                self._link_objects[link_name] = traitlets.dlink(*links)
            else:
                self._link_objects[link_name] = traitlets.link(*links)

        ##callbacks
        default_callbacks = {}
        if "default" in self._callbacks:
            default_callbacks = self._callbacks["default"]

        state_callbacks = {}
        if state in self._callbacks:
            state_callbacks = self._callbacks[state]

        callbacks = default_callbacks.copy()
        callbacks.update(state_callbacks)

        for obj_name in callbacks:
            for type in callbacks[obj_name]:
                if hasattr(self._object_list[obj_name], type):
                    if type == "on_trait_change":
                        self._object_list[obj_name].on_trait_change(*callbacks[obj_name][type])
                    elif type == "on_click":
                        self._object_list[obj_name].on_click(callbacks[obj_name][type][0])
                    elif type == "on_submit":
                        self._object_list[obj_name].on_submit(callbacks[obj_name][type][0])
                    else:
                        raise ValueError("the object: " + obj_name + " has no method called: " + type)
        ##children
        default_children = {}
        if "default" in self._children:
            default_children = self._children["default"]

        state_children = {}
        if state in self._children:
            state_children = self._children[state]

        children = default_children.copy()
        children.update(state_children)

        for obj_name in children:
            if children[obj_name][0]:
                for i, title in enumerate(children[obj_name][2]):
                    self._object_list[obj_name].set_title(i, title)
            children_list = [self._object_list[child_name] for child_name in children[obj_name][1]]
            self._object_list[obj_name].children = children_list
Beispiel #34
0
 def _link_children(self):
     """
     Links the visible property of the container to the toggle value.
     """
     link((self._checkbox, str('value')), (self._container, str('visible')))
Beispiel #35
0
 def _link_children(self):
     """
     Links the visible property of the container to the toggle value.
     """
     from IPython.utils.traitlets import link
     link((self._checkbox, str('value')), (self._container, str('visible')))
Beispiel #36
0
    def _update(self, state="default"):
        for obj_name in self._object_list:
            ##apply attributes
            default_style = {}
            if obj_name in self._display_list:
                default_style = self._default_display_style
            elif obj_name in self._io_list:
                default_style = self._default_io_style

            default_attributes = {}
            if "default" in self._attributes:
                if obj_name in self._attributes["default"]:
                    default_attributes = self._attributes["default"][obj_name]

            state_attributes = {}
            if state in self._attributes:
                if obj_name in self._attributes[state]:
                    state_attributes = self._attributes[state][obj_name]

            attributes = default_style.copy()
            attributes.update(default_attributes)
            attributes.update(state_attributes)

            if not "visible" in attributes:
                attributes["visible"] = False

            self.set_attributes(obj_name, **attributes)

        ##apply links
        for link_name in self._link_object:  #clear link objects
            self._link_object[link_name].unlink()
        self._link_objects = {}

        default_links = {}
        if "default" in self._links:
            default_links = self._links["default"]

        state_links = {}
        if state in self._links:
            state_links = self._links[state]

        links_dict = default_links.copy()
        links_dict.update(state_links)

        for link_name in links_dict:
            directional, links_list = links_dict[link_name]
            links = []
            for link in links_list:
                links.append((self._object_list[link[0]], link[1]))
            if directional:
                self._link_objects[link_name] = traitlets.dlink(*links)
            else:
                self._link_objects[link_name] = traitlets.link(*links)

        ##callbacks
        default_callbacks = {}
        if "default" in self._callbacks:
            default_callbacks = self._callbacks["default"]

        state_callbacks = {}
        if state in self._callbacks:
            state_callbacks = self._callbacks[state]

        callbacks = default_callbacks.copy()
        callbacks.update(state_callbacks)

        for obj_name in callbacks:
            for type in callbacks[obj_name]:
                if hasattr(self._object_list[obj_name], type):
                    if type == "on_trait_change":
                        self._object_list[obj_name].on_trait_change(
                            *callbacks[obj_name][type])
                    elif type == "on_click":
                        self._object_list[obj_name].on_click(
                            callbacks[obj_name][type][0])
                    elif type == "on_submit":
                        self._object_list[obj_name].on_submit(
                            callbacks[obj_name][type][0])
                    else:
                        raise ValueError("the object: " + obj_name +
                                         " has no method called: " + type)
        ##children
        default_children = {}
        if "default" in self._children:
            default_children = self._children["default"]

        state_children = {}
        if state in self._children:
            state_children = self._children[state]

        children = default_children.copy()
        children.update(state_children)

        for obj_name in children:
            if children[obj_name][0]:
                for i, title in enumerate(children[obj_name][2]):
                    self._object_list[obj_name].set_title(i, title)
            children_list = [
                self._object_list[child_name]
                for child_name in children[obj_name][1]
            ]
            self._object_list[obj_name].children = children_list
Beispiel #37
0
    def plot_panel(self):
        # create draw mode controls.  NOTE: should only be called once.
        cbar = Checkbox(description="Colorbar")
        link((self.model, "colorbar"), (cbar, "value"))

        interact = Checkbox(description="Interactive")
        link((self.model, "interactive"), (interact, "value"))

        plug_select = Checkbox(description="Line Selection")
        link((self.model, "selectlines"), (plug_select, "value"))

        autoupdate = Checkbox(description="Auto Update")
        link((self.model, "autoupdate"), (autoupdate, "value"))

        plugin2 = Checkbox(description='Cursor')
        plugin3 = Checkbox(description='plugin3')
        fwidth = FloatText(description='Plot width')
        fheight = FloatText(description='Plot height')
        link((self.model, "figwidth"), (fwidth, "value"))
        link((self.model, "figheight"), (fheight, "value"))

        f = Text(description="Function:")
        link((self.model, "user_f"), (f, "value"))
        fapp = Button(color='black',
                      background_color='AliceBlue',
                      description="Apply")
        fapp.on_click(lambda x: self.model.apply_userf(name='apply clicked'))

        #plugins = HBox([plugin1,plugin2,plugin3])
        #more = Checkbox(description="More Options")### LINK IT
        #link((self, "moreopt"), (more, "value"))
        #popmore = Popup(children=[VBox([HBox([plug_select,plugin2,plugin3]),
        #                                HBox([f,fapp]),
        #                                VBox([fwidth, fheight])
        #                              ])],
        #                description='Advanced', button_text='Advanced')

        more = Checkbox(description="Advanced")
        link((self.model, "advancedbox"), (more, "value"))

        popmore = VBox([
            HBox([
                plug_select,
                plugin2,
                #		plugin3
            ]),
            HBox([f, fapp]),
            HBox([fwidth, fheight])
        ])
        link((self.model, "advancedbox"), (popmore, "visible"))

        cmapcheck = Checkbox(description="Colormap")
        link((self.model, "cmapbox"), (cmapcheck, "value"))

        cmap = Dropdown(description="Colormap", values=self.model.COLORMAPS)
        link((self.model, "colormap"), (cmap, "value"))
        link((self.model, "cmapbox"), (cmap, "visible"))

        colorcheck = Checkbox(description="Color")
        link((self.model, "colorbox"), (colorcheck, "value"))

        color = Dropdown(description="Color", values=self.model.COLORS)
        link((self.model, "color"), (color, "value"))
        link((self.model, "colorbox"), (color, "visible"))

        kind = Dropdown(description="Plot Type", values=PLOTPARSER.keys())
        link((self.model, "kind"), (kind, "value"))

        return ControlPanel(title="Plot Settings",
                            children=[
                                VBox([autoupdate, kind]),
                                HBox([cbar, interact]),
                                HBox([colorcheck, cmapcheck]),
                                HBox([more]), cmap, color, popmore
                            ])
Beispiel #38
0
    def slicing_panel(self):
        """ create spectrum controls.  NOTE: should only be called once."""

        model = self.model  #For readability

        # ALL WIDGETS ARE CAPITALIZED.
        #AXIS = RadioButtons(values=[0,1],description="Axis")
        #link((model, "slice_axis"), (AXIS, "value"))

        SPECSTART = FloatSlider(
            description="Spec Start",
            min=model.specslice_position_start)  #Will not try to update

        link((model, "specslice_position_start"), (SPECSTART, "value"))
        link((model, "specstep"), (SPECSTART, "step"))
        link((model, "specslider_start"),
             (SPECSTART,
              "min"))  # Start end values (IE slider_min / slider_max)
        link((model, "specslider_end"), (SPECSTART, "max"))

        SPECEND = FloatSlider(
            description="Spec End",
            max=model.specslice_position_end)  # Will not try to update

        link((model, "specslice_position_end"), (SPECEND, "value"))
        link((model, "specstep"), (SPECEND, "step"))
        link((model, "specslider_start"), (SPECEND, "min"))
        link((model, "specslider_end"), (SPECEND, "max"))

        # SPACING WIDGET
        SPECSPACING = IntText(description="Spec Sample by", value=1)
        link((model, "specspacing"), (SPECSPACING, "value"))

        TIMESTART = FloatSlider(description="Var Start",
                                min=model.timeslice_position_start)

        link((model, "timeslice_position_start"), (TIMESTART, "value"))
        link((model, "timestep"), (TIMESTART, "step"))
        link((model, "timeslider_start"), (TIMESTART, "min"))
        link((model, "timeslider_end"), (TIMESTART, "max"))

        TIMEEND = FloatSlider(description="Var End",
                              max=model.timeslice_position_end)
        link((model, "timeslice_position_end"), (TIMEEND, "value"))
        link((model, "timestep"), (TIMEEND, "step"))
        link((model, "timeslider_start"), (TIMEEND, "min"))
        link((model, "timeslider_end"), (TIMEEND, "max"))

        TIMESPACING = IntText(description="Var Sample by", value=1)
        link((model, "timespacing"), (TIMESPACING, "value"))

        speccheck = Checkbox(description="Spectral Axis")
        link((model, "specbox"), (speccheck, "value"))
        SPECRANGED = VBox([SPECSTART, SPECEND, SPECSPACING])
        link((model, "specbox"), (SPECRANGED, "visible"))

        timecheck = Checkbox(description="Variation Axis")
        link((model, "timebox"), (timecheck, "value"))
        TIMERANGED = VBox([TIMESTART, TIMEEND, TIMESPACING])
        link((model, "timebox"), (TIMERANGED, "visible"))

        return ControlPanel(
            title="Slicing/Sampling",
            children=[HBox([speccheck, timecheck]), SPECRANGED, TIMERANGED])
    def INOUT_panel(self):
        # create correlation controls. NOTE: should only be called once.
        incheck = Checkbox(description = 'Import')
        link((self.model, "inbox"), (incheck,"value"))
        outcheck = Checkbox(description = 'Export')
        link((self.model, "outbox"), (outcheck,"value"))
        
        #loaddata = Checkbox(description="Testdata")
        #link((self.model, "load_spec"), (loaddata, "value"))
        #testdataset = Text(description = "")
        #link((self.model, "testdataset"), (testdataset, "value"))
     
        filename = Text(description = "")
        link((self.model, "file_name"), (filename, "value"))
        loadbutton = Button(color='black',background_color='AliceBlue',description="Load")
        loadbutton.on_click(lambda x: self.model.load_from_ns())
        boxi = HBox([filename,loadbutton])
        #link((self.model, "load_spec"), (specbox, "visible"))

#        loadfile = Checkbox(description="NB Variable") #Test Data
#        link((self.model, "load_file"), (loadfile, "value"))

        
        #                filebox = HBox([loadbutton, filename])
        #link((self.model, "load_file"), (filebox, "visible"))
        
        #boxi = VBox([
                     #HBox([loaddata, loadfile]),
                     #loaddata,
                     #             specbox,
                     #filebox,
                     #            ])
        link((self.model, "inbox"), (boxi,"visible"))

        saveplot = Button(color='black',background_color='AliceBlue',description='Save Plot')
        saveplot.on_click(lambda x: self.model.save_plot())
        savespec = Button(color='black',background_color='AliceBlue',description='Export Dataset')
        savespec.on_click(lambda x: self.model.save_to_ns())
        savespecas = Text(description="")
        link((self.model,"save_spec_as"),(savespecas,"value"))
        
        boxo = VBox([
                    savespecas,
                    HBox([saveplot,savespec]),
                    ])
        link((self.model, "outbox"), (boxo,"visible"))
        
        #reset = Button(color='white',background_color='violet',description='Reset Defaults')
        #reset.on_click(lambda x: self.model.)
                       
        #redraw = Button(description="Redraw")
        #redraw.on_click(lambda x: self.model.draw())

        return ControlPanel(title="Import/Export Dataset",
                            children=[HBox([
                                            VBox([incheck,outcheck]),
                                            VBox([boxi,boxo])
                                            ])
                                     ]
                            )
Beispiel #40
0
    def INOUT_panel(self):
        # create correlation controls. NOTE: should only be called once.
        incheck = Checkbox(description='Import')
        link((self.model, "inbox"), (incheck, "value"))
        outcheck = Checkbox(description='Export')
        link((self.model, "outbox"), (outcheck, "value"))

        #loaddata = Checkbox(description="Testdata")
        #link((self.model, "load_spec"), (loaddata, "value"))
        #testdataset = Text(description = "")
        #link((self.model, "testdataset"), (testdataset, "value"))

        filename = Text(description="")
        link((self.model, "file_name"), (filename, "value"))
        loadbutton = Button(color='black',
                            background_color='AliceBlue',
                            description="Load")
        loadbutton.on_click(lambda x: self.model.load_from_ns())
        boxi = HBox([filename, loadbutton])
        #link((self.model, "load_spec"), (specbox, "visible"))

        #        loadfile = Checkbox(description="NB Variable") #Test Data
        #        link((self.model, "load_file"), (loadfile, "value"))

        #                filebox = HBox([loadbutton, filename])
        #link((self.model, "load_file"), (filebox, "visible"))

        #boxi = VBox([
        #HBox([loaddata, loadfile]),
        #loaddata,
        #             specbox,
        #filebox,
        #            ])
        link((self.model, "inbox"), (boxi, "visible"))

        saveplot = Button(color='black',
                          background_color='AliceBlue',
                          description='Save Plot')
        saveplot.on_click(lambda x: self.model.save_plot())
        savespec = Button(color='black',
                          background_color='AliceBlue',
                          description='Export Dataset')
        savespec.on_click(lambda x: self.model.save_to_ns())
        savespecas = Text(description="")
        link((self.model, "save_spec_as"), (savespecas, "value"))

        boxo = VBox([
            savespecas,
            HBox([saveplot, savespec]),
        ])
        link((self.model, "outbox"), (boxo, "visible"))

        #reset = Button(color='white',background_color='violet',description='Reset Defaults')
        #reset.on_click(lambda x: self.model.)

        #redraw = Button(description="Redraw")
        #redraw.on_click(lambda x: self.model.draw())

        return ControlPanel(
            title="Import/Export Dataset",
            children=[HBox([VBox([incheck, outcheck]),
                            VBox([boxi, boxo])])])
Beispiel #41
0
from IPython.html.widgets import *
from IPython.display import display
from IPython.utils.traitlets import link
code = Textarea(description="Source:", value="Cool math: $\\frac{F}{m}=a$")
preview = Latex()
display(code, preview)
mylink = link((code, 'value'), (preview, 'value'))
Beispiel #42
0
__FILENAME__ = displaying
from IPython.html.widgets import *
from IPython.display import display
w = TextWidget(value="test")
display(w)
w.keys

########NEW FILE########
__FILENAME__ = link
from IPython.html.widgets import *
from IPython.display import display
from IPython.utils.traitlets import link
code = TextareaWidget(description="Source:", value="Cool math: $\\frac{F}{m}=a$")
preview = LatexWidget()
display(code, preview)
mylink = link((code, 'value'), (preview, 'value'))
########NEW FILE########
__FILENAME__ = on_submit
from IPython.html.widgets import *
w = TextWidget()
def handle_submit(sender):
    print(sender.value)
    sender.value = ''
w.on_submit(handle_submit)
w

########NEW FILE########
__FILENAME__ = on_trait_change
from IPython.html.widgets import *
w = TextWidget()
def handle_submit(name, new):
    def plot_panel(self):
        # create draw mode controls.  NOTE: should only be called once.
        cbar = Checkbox(description="Colorbar")
        link((self.model, "colorbar"), (cbar, "value"))

        interact = Checkbox(description="Interactive")
        link((self.model, "interactive"), (interact, "value"))

        plug_select = Checkbox(description="Line Selection")
        link((self.model, "selectlines"), (plug_select, "value"))

        autoupdate = Checkbox(description="Auto Update")
        link((self.model, "autoupdate"), (autoupdate, "value"))
        
        plugin2= Checkbox(description='Cursor')
        plugin3= Checkbox(description='plugin3')
        fwidth = FloatText(description='Plot width')
        fheight = FloatText(description='Plot height')
        link((self.model, "figwidth"), (fwidth, "value"))
        link((self.model, "figheight"), (fheight, "value"))
        
        
        f = Text(description="Function:")
        link((self.model,"user_f"),(f,"value"))
        fapp = Button(color='black',background_color='AliceBlue',description = "Apply")
        fapp.on_click(lambda x: self.model.apply_userf(name='apply clicked'))

        #plugins = HBox([plugin1,plugin2,plugin3])
        #more = Checkbox(description="More Options")### LINK IT
        #link((self, "moreopt"), (more, "value"))
        #popmore = Popup(children=[VBox([HBox([plug_select,plugin2,plugin3]),
        #                                HBox([f,fapp]),
        #                                VBox([fwidth, fheight])
        #                              ])],
        #                description='Advanced', button_text='Advanced')

        more = Checkbox(description="Advanced")
        link((self.model, "advancedbox"), (more, "value"))

        popmore = VBox([HBox([plug_select,
									plugin2,
							#		plugin3
									]),
                        HBox([f,fapp]),
                        HBox([fwidth, fheight])
                        ])
        link((self.model, "advancedbox"), (popmore,"visible"))

        cmapcheck = Checkbox(description="Colormap")
        link((self.model, "cmapbox"), (cmapcheck, "value"))

        cmap = Dropdown(description="Colormap",values=self.model.COLORMAPS)
        link((self.model,"colormap"),(cmap,"value"))
        link((self.model,"cmapbox"),(cmap,"visible"))
        
        colorcheck = Checkbox(description="Color")
        link((self.model, "colorbox"), (colorcheck, "value"))

        color = Dropdown(description="Color",values=self.model.COLORS)
        link((self.model, "color"), (color, "value"))
        link((self.model,"colorbox"),(color,"visible"))

        kind = Dropdown(description="Plot Type", values=PLOTPARSER.keys())
        link((self.model, "kind"), (kind, "value"))


        return ControlPanel(title="Plot Settings", 
                            children=[
                                VBox([autoupdate,kind]),
                                HBox([cbar, interact]),
                                HBox([colorcheck, cmapcheck]),
                                HBox([more]),
                                cmap,
                                color,
                                popmore
                                ]
                            )