def __init__(self, par): self.par = par # Define widgets. self.value_text = FloatText(description=par.name, min=self.par.min, max=self.par.max) self.min_text = FloatText(description='min', max=self.par.max) self.max_text = FloatText(description='max', min=self.par.min) self.min_checkbox = Checkbox(description='min') self.max_checkbox = Checkbox(description='max') self.vary_checkbox = Checkbox(description='vary') # Set widget values and visibility. if par.value is not None: self.value_text.value = self.par.value min_unset = self.par.min is None or self.par.min == -np.inf max_unset = self.par.max is None or self.par.max == np.inf self.min_checkbox.value = not min_unset self.min_text.visible = not min_unset self.min_text.value = self.par.min self.max_checkbox.value = not max_unset self.max_text.visible = not max_unset self.max_text.value = self.par.max self.vary_checkbox.value = self.par.vary # Configure widgets to sync with par attributes. self.value_text.on_trait_change(self._on_value_change, 'value') self.min_text.on_trait_change(self._on_min_value_change, 'value') self.max_text.on_trait_change(self._on_max_value_change, 'value') self.min_checkbox.on_trait_change(self._on_min_checkbox_change, 'value') self.max_checkbox.on_trait_change(self._on_max_checkbox_change, 'value') self.vary_checkbox.on_trait_change(self._on_vary_change, 'value')
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 ])
def AttenuationWidgetTBL(): i = interact(WaveVelandSkindWidgetTBL, epsr=FloatText(value=9.), sigma=FloatSlider(min=-4., max=1., step=0.5, value=-1.5)) return i