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")) takeout = Checkbox(description='takeit') link((self.model, "take"), (takeout, "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")) filename = Text(description="") link((self.model, "file_name"), (filename, "value")) savetake = Button(color='black', background_color='AliceBlue', description='') saveplot.on_click(lambda x: self.model.take_out()) takename = Text(description="") takebutton = Button(color='black', background_color='AliceBlue', description="Take SON") #takebutton.on_click(lambda x: self.model.load_from_ns()) boxl = HBox([takename, takebutton]) link((self.model, "take"), (boxl, "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, takeout]), VBox([boxi, boxo, boxl]) ]) ])
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 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")) Splot = Checkbox(description="Standardplot") link((self.model, "Standardplot"), (Splot, "value")) loadit = Checkbox(description='load') link((self.model, "load"), (loadit, "value")) plott = Dropdown(description="Corr Plot", values=PLOTPARSER.keys()) link((self.model, "plottype"), (kind, "value")) return ControlPanel(title="Plot Settings", children=[ VBox([autoupdate, kind]), HBox([cbar, interact]), HBox([colorcheck, cmapcheck]), HBox([more]), cmap, color, popmore, Splot, loadit, plott, ])
def status_printer(_, total=None, desc=None, ncols=None): """ Manage the printing of an IPython/Jupyter Notebook progress bar widget. """ # Fallback to text bar if there's no total # DEPRECATED: replaced with an 'info' style bar # if not total: # return super(tqdm_notebook, tqdm_notebook).status_printer(file) # fp = file # Prepare IPython progress bar try: if total: pbar = IntProgress(min=0, max=total) else: # No total? Show info style bar with no progress tqdm status pbar = IntProgress(min=0, max=1) pbar.value = 1 pbar.bar_style = 'info' except NameError: # #187 #451 #558 raise ImportError( "IntProgress not found. Please update jupyter and ipywidgets." " See https://ipywidgets.readthedocs.io/en/stable" "/user_install.html") if desc: pbar.description = desc if IPYW >= 7: pbar.style.description_width = 'initial' # Prepare status text ptext = HTML() # Only way to place text to the right of the bar is to use a container container = HBox(children=[pbar, ptext]) # Prepare layout if ncols is not None: # use default style of ipywidgets # ncols could be 100, "100px", "100%" ncols = str(ncols) # ipywidgets only accepts string try: if int(ncols) > 0: # isnumeric and positive ncols += 'px' except ValueError: pass pbar.layout.flex = '2' container.layout.width = ncols container.layout.display = 'inline-flex' container.layout.flex_flow = 'row wrap' display(container) def print_status(s='', close=False, bar_style=None, desc=None): # Note: contrary to native tqdm, s='' does NOT clear bar # goal is to keep all infos if error happens so user knows # at which iteration the loop failed. # Clear previous output (really necessary?) # clear_output(wait=1) # Get current iteration value from format_meter string if total: # n = None if s: npos = s.find(r'/|/') # cause we use bar_format=r'{n}|...' # Check that n can be found in s (else n > total) if npos >= 0: n = float(s[:npos]) # get n from string s = s[npos + 3:] # remove from string # Update bar with current n value if n is not None: pbar.value = n # Print stats if s: # never clear the bar (signal: s='') s = s.replace('||', '') # remove inesthetical pipes s = escape(s) # html escape special characters (like '?') ptext.value = s # Change bar style if bar_style: # Hack-ish way to avoid the danger bar_style being overridden by # success because the bar gets closed after the error... if not (pbar.bar_style == 'danger' and bar_style == 'success'): pbar.bar_style = bar_style # Special signal to close the bar if close and pbar.bar_style != 'danger': # hide only if no error try: container.close() except AttributeError: container.visible = False # Update description if desc: pbar.description = desc if IPYW >= 7: pbar.style.description_width = 'initial' return print_status
def _repr_html_(self): box = HBox() box.children = [self.value_text, self.vary_checkbox, self.min_checkbox, self.min_text, self.max_checkbox, self.max_text] display(box)
def status_printer(_, total=None, desc=None): """ Manage the printing of an IPython/Jupyter Notebook progress bar widget. """ # Fallback to text bar if there's no total # DEPRECATED: replaced with an 'info' style bar # if not total: # return super(tqdm_notebook, tqdm_notebook).status_printer(file) # fp = file # Prepare IPython progress bar if total: pbar = IntProgress(min=0, max=total) else: # No total? Show info style bar with no progress tqdm status pbar = IntProgress(min=0, max=1) pbar.value = 1 pbar.bar_style = 'info' if desc: pbar.description = desc # Prepare status text ptext = HTML() # Only way to place text to the right of the bar is to use a container container = HBox(children=[pbar, ptext]) display(container) def print_status(s='', close=False, bar_style=None, desc=None): # Note: contrary to native tqdm, s='' does NOT clear bar # goal is to keep all infos if error happens so user knows # at which iteration the loop failed. # Clear previous output (really necessary?) # clear_output(wait=1) # Get current iteration value from format_meter string if total: # n = None if s: npos = s.find(r'/|/') # cause we use bar_format=r'{n}|...' # Check that n can be found in s (else n > total) if npos >= 0: n = int(s[:npos]) # get n from string s = s[npos + 3:] # remove from string # Update bar with current n value if n is not None: pbar.value = n # Print stats if s: # never clear the bar (signal: s='') s = s.replace('||', '') # remove inesthetical pipes s = escape(s) # html escape special characters (like '?') ptext.value = s # Change bar style if bar_style: # Hack-ish way to avoid the danger bar_style being overriden by # success because the bar gets closed after the error... if not (pbar.bar_style == 'danger' and bar_style == 'success'): pbar.bar_style = bar_style # Special signal to close the bar if close and pbar.bar_style != 'danger': # hide only if no error try: container.close() except AttributeError: container.visible = False # Update description if desc: pbar.description = desc return print_status