class IntSlider(_BoundedInt): """Slider widget that represents an integer bounded from above and below. """ _view_name = Unicode('IntSliderView').tag(sync=True) _model_name = Unicode('IntSliderModel').tag(sync=True) step = CInt(1, help="Minimum step to increment the value").tag(sync=True) orientation = CaselessStrEnum( values=['horizontal', 'vertical'], default_value='horizontal', help="Vertical or horizontal.").tag(sync=True) readout = Bool( True, help="Display the current value of the slider next to it.").tag( sync=True) readout_format = NumberFormat('d', help="Format for the readout").tag(sync=True) continuous_update = Bool( True, help="Update the value of the widget as the user is holding the slider." ).tag(sync=True) disabled = Bool(False, help="Enable or disable user changes").tag(sync=True) style = InstanceDict(SliderStyle).tag(sync=True, **widget_serialization) behavior = CaselessStrEnum( values=['drag-tap', 'drag-snap', 'tap', 'drag', 'snap'], default_value='drag-tap', help="Slider dragging behavior.").tag(sync=True)
class FloatProgress(_BoundedFloat): """ Displays a progress bar. Parameters ----------- value : float position within the range of the progress bar min : float minimal position of the slider max : float maximal position of the slider step : float step of the progress bar description : str name of the progress bar bar_style: {'success', 'info', 'warning', 'danger', ''}, optional color of the progress bar, default is '' (blue) colors are: 'success'-green, 'info'-light blue, 'warning'-orange, 'danger'-red """ _view_name = Unicode('ProgressView', sync=True) orientation = CaselessStrEnum(values=['horizontal', 'vertical'], default_value='horizontal', help="Vertical or horizontal.", sync=True) bar_style = CaselessStrEnum( values=['success', 'info', 'warning', 'danger', ''], default_value='', allow_none=True, sync=True, help="""Use a predefined styling for the progess bar.""")
class Box(DOMWidget): """Displays multiple widgets in a group.""" _model_name = Unicode('BoxModel', sync=True) _view_name = Unicode('BoxView', sync=True) # Child widgets in the container. # Using a tuple here to force reassignment to update the list. # When a proper notifying-list trait exists, that is what should be used here. children = Tuple(sync=True, **widget_serialization) _overflow_values = ['visible', 'hidden', 'scroll', 'auto', 'initial', 'inherit', ''] overflow_x = CaselessStrEnum( values=_overflow_values, default_value='', sync=True, help="""Specifies what happens to content that is too large for the rendered region.""") overflow_y = CaselessStrEnum( values=_overflow_values, default_value='', sync=True, help="""Specifies what happens to content that is too large for the rendered region.""") box_style = CaselessStrEnum( values=['success', 'info', 'warning', 'danger', ''], default_value='', allow_none=True, sync=True, help="""Use a predefined styling for the box.""") def __init__(self, children = (), **kwargs): kwargs['children'] = children super(Box, self).__init__(**kwargs) self.on_displayed(Box._fire_children_displayed) def _fire_children_displayed(self): for child in self.children: child._handle_displayed()
class FlexBox(Box): # TODO: Deprecated in 5.0 (entire class) """Displays multiple widgets using the flexible box model.""" _view_name = Unicode('FlexBoxView').tag(sync=True) _model_name = Unicode('FlexBoxModel').tag(sync=True) orientation = CaselessStrEnum(values=['vertical', 'horizontal'], default_value='vertical').tag(sync=True) flex = Int(help="""Specify the flexible-ness of the model.""").tag( sync=True) def _flex_changed(self, name, old, new): new = min(max(0, new), 2) if self.flex != new: self.flex = new _locations = ['start', 'center', 'end', 'baseline', 'stretch'] pack = CaselessStrEnum(values=_locations, default_value='start').tag(sync=True) align = CaselessStrEnum(values=_locations, default_value='start').tag(sync=True) def __init__(self, *pargs, **kwargs): warn( 'FlexBox is deprecated in ipywidgets 5.0. Use Box and Box.layout instead.', DeprecationWarning) super(FlexBox, self).__init__(*pargs, **kwargs)
class FloatProgress(_BoundedFloat): """ Displays a progress bar. Parameters ----------- value : float position within the range of the progress bar min : float minimal position of the slider max : float maximal position of the slider description : str name of the progress bar orientation : {'horizontal', 'vertical'} default is 'horizontal', orientation of the progress bar bar_style: {'success', 'info', 'warning', 'danger', ''} color of the progress bar, default is '' (blue) colors are: 'success'-green, 'info'-light blue, 'warning'-orange, 'danger'-red """ _view_name = Unicode('ProgressView').tag(sync=True) _model_name = Unicode('FloatProgressModel').tag(sync=True) orientation = CaselessStrEnum( values=['horizontal', 'vertical'], default_value='horizontal', help="Vertical or horizontal.").tag(sync=True) bar_style = CaselessStrEnum( values=['success', 'info', 'warning', 'danger', ''], default_value='', allow_none=True, help="Use a predefined styling for the progess bar.").tag(sync=True) style = InstanceDict(ProgressStyle).tag(sync=True, **widget_serialization)
class DOMWidget(Widget): visible = Bool(True, allow_none=True, help="Whether the widget is visible. False collapses the empty space, while None preserves the empty space.", sync=True) _css = Tuple(sync=True, help="CSS property list: (selector, key, value)") _dom_classes = Tuple(sync=True, help="DOM classes applied to widget.$el.") width = CUnicode(sync=True) height = CUnicode(sync=True) # A default padding of 2.5 px makes the widgets look nice when displayed inline. padding = CUnicode(sync=True) margin = CUnicode(sync=True) color = Color(None, allow_none=True, sync=True) background_color = Color(None, allow_none=True, sync=True) border_color = Color(None, allow_none=True, sync=True) border_width = CUnicode(sync=True) border_radius = CUnicode(sync=True) border_style = CaselessStrEnum(values=[ # http://www.w3schools.com/cssref/pr_border-style.asp 'none', 'hidden', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset', 'initial', 'inherit', ''], default_value='', sync=True) font_style = CaselessStrEnum(values=[ # http://www.w3schools.com/cssref/pr_font_font-style.asp 'normal', 'italic', 'oblique', 'initial', 'inherit', ''], default_value='', sync=True) font_weight = CaselessStrEnum(values=[ # http://www.w3schools.com/cssref/pr_font_weight.asp 'normal', 'bold', 'bolder', 'lighter', 'initial', 'inherit', ''] + list(map(str, range(100,1000,100))), default_value='', sync=True) font_size = CUnicode(sync=True) font_family = Unicode(sync=True) def __init__(self, *pargs, **kwargs): super(DOMWidget, self).__init__(*pargs, **kwargs) def _validate_border(name, old, new): if new is not None and new != '': if name != 'border_width' and not self.border_width: self.border_width = 1 if name != 'border_style' and self.border_style == '': self.border_style = 'solid' self.on_trait_change(_validate_border, ['border_width', 'border_style', 'border_color'])
class DatasetConfig(Configurable): # not configurable n_sample = Integer(help='Total number of data counted internally') # configurable descriptor = CaselessStrEnum( ['symmetry_function', 'weighted_symmetry_function'], default_value='symmetry_function', help='Name of descriptor dataset used for input of HDNNP').tag( config=True) parameters = Dict( trait=List, help='Parameters used for the specified descriptor dataset. ' 'Set as Dict{key: List[Tuple(parameters)]}. ' 'This will be passed to descriptor dataset as keyword arguments. ' 'ex.) {"type2": [(5.0, 0.01, 2.0)]}').tag(config=True) property_ = CaselessStrEnum( ['interatomic_potential'], default_value='interatomic_potential', help='Name of property dataset to be optimized by HDNNP').tag( config=True) preprocesses = List( trait=Tuple(CaselessStrEnum(['pca', 'scaling', 'standardization']), Tuple(), Dict()), help='Preprocess to be applied for input of HDNNP (=descriptor). ' 'Set as List[Tuple(Str(name), Tuple(args), Dict{kwargs})]. ' 'Each preprocess instance will be initialized with ' '(*args, **kwargs). ' 'ex.) [("pca", (20,), {})]').tag(config=True) remake = Bool( default_value=False, help='If the given data file and the loaded dataset are not ' 'compatible, automatically recalculate and overwrite it.').tag( config=True)
class FloatLogSlider(_BoundedLogFloat): """ Slider/trackbar of logarithmic floating values with the specified range. Parameters ---------- value : float position of the slider base : float base of the logarithmic scale. Default is 10 min : float minimal position of the slider in log scale, i.e., actual minimum is base ** min max : float maximal position of the slider in log scale, i.e., actual maximum is base ** max step : float step of the trackbar, denotes steps for the exponent, not the actual value description : str name of the slider orientation : {'horizontal', 'vertical'} default is 'horizontal', orientation of the slider readout : {True, False} default is True, display the current value of the slider next to it behavior : str slider handle and connector dragging behavior. Default is 'drag-tap'. readout_format : str default is '.3g', specifier for the format function used to represent slider value for human consumption, modeled after Python 3's format specification mini-language (PEP 3101). """ _view_name = Unicode('FloatLogSliderView').tag(sync=True) _model_name = Unicode('FloatLogSliderModel').tag(sync=True) step = CFloat( 0.1, allow_none=True, help="Minimum step in the exponent to increment the value").tag( sync=True) orientation = CaselessStrEnum( values=['horizontal', 'vertical'], default_value='horizontal', help="Vertical or horizontal.").tag(sync=True) readout = Bool( True, help="Display the current value of the slider next to it.").tag( sync=True) readout_format = NumberFormat('.3g', help="Format for the readout").tag(sync=True) continuous_update = Bool( True, help="Update the value of the widget as the user is holding the slider." ).tag(sync=True) disabled = Bool(False, help="Enable or disable user changes").tag(sync=True) base = CFloat(10., help="Base for the logarithm").tag(sync=True) style = InstanceDict(SliderStyle).tag(sync=True, **widget_serialization) behavior = CaselessStrEnum( values=['drag-tap', 'drag-snap', 'tap', 'drag', 'snap'], default_value='drag-tap', help="Slider dragging behavior.").tag(sync=True)
class IntProgress(_BoundedInt): """Progress bar that represents an integer bounded by a minimum and maximum value.""" _view_name = Unicode('ProgressView', sync=True) orientation = CaselessStrEnum(values=['horizontal', 'vertical'], default_value='horizontal', help="Vertical or horizontal.", sync=True) bar_style = CaselessStrEnum( values=['success', 'info', 'warning', 'danger', ''], default_value='', allow_none=True, sync=True, help="""Use a predefined styling for the progess bar.""")
class IntProgress(_BoundedInt): """Progress bar that represents an integer bounded from above and below. """ _view_name = Unicode('ProgressView').tag(sync=True) _model_name = Unicode('ProgressModel').tag(sync=True) orientation = CaselessStrEnum(values=['horizontal', 'vertical'], default_value='horizontal', help="Vertical or horizontal.").tag(sync=True) bar_style = CaselessStrEnum( values=['success', 'info', 'warning', 'danger', ''], default_value='', help="""Use a predefined styling for the progess bar.""").tag(sync=True)
class FloatRangeSlider(_BoundedFloatRange): """ Slider/trackbar that represents a pair of floats bounded by minimum and maximum value. Parameters ---------- value : float tuple range of the slider displayed min : float minimal position of the slider max : float maximal position of the slider step : float step of the trackbar description : str name of the slider orientation : {'horizontal', 'vertical'} default is 'horizontal' readout : {True, False} default is True, display the current value of the slider next to it behavior : str slider handle and connector dragging behavior. Default is 'drag-tap'. readout_format : str default is '.2f', specifier for the format function used to represent slider value for human consumption, modeled after Python 3's format specification mini-language (PEP 3101). """ _view_name = Unicode('FloatRangeSliderView').tag(sync=True) _model_name = Unicode('FloatRangeSliderModel').tag(sync=True) step = CFloat(0.1, allow_none=True, help="Minimum step to increment the value").tag(sync=True) orientation = CaselessStrEnum( values=['horizontal', 'vertical'], default_value='horizontal', help="Vertical or horizontal.").tag(sync=True) readout = Bool( True, help="Display the current value of the slider next to it.").tag( sync=True) readout_format = NumberFormat('.2f', help="Format for the readout").tag(sync=True) continuous_update = Bool( True, help="Update the value of the widget as the user is sliding the slider." ).tag(sync=True) disabled = Bool(False, help="Enable or disable user changes").tag(sync=True) style = InstanceDict(SliderStyle).tag(sync=True, **widget_serialization) behavior = CaselessStrEnum( values=['drag-tap', 'drag-snap', 'tap', 'drag', 'snap'], default_value='drag-tap', help="Slider dragging behavior.").tag(sync=True)
class Box(DOMWidget, CoreWidget): """Displays multiple widgets in a group.""" _model_module = Unicode('jupyter-js-widgets').tag(sync=True) _view_module = Unicode('jupyter-js-widgets').tag(sync=True) _model_name = Unicode('BoxModel').tag(sync=True) _view_name = Unicode('BoxView').tag(sync=True) # Child widgets in the container. # Using a tuple here to force reassignment to update the list. # When a proper notifying-list trait exists, that is what should be used here. children = Tuple().tag(sync=True, **widget_serialization) box_style = CaselessStrEnum( values=['success', 'info', 'warning', 'danger', ''], default_value='', help="""Use a predefined styling for the box.""").tag(sync=True) def __init__(self, children=(), **kwargs): kwargs['children'] = children super(Box, self).__init__(**kwargs) self.on_displayed(Box._fire_children_displayed) def _fire_children_displayed(self): for child in self.children: child._handle_displayed()
class ToggleButtons(_Selection): """Group of toggle buttons that represent an enumeration. Only one toggle button can be toggled at any point in time. Parameters ---------- {selection_params} tooltips: list Tooltip for each button. If specified, must be the same length as `options`. icons: list Icons to show on the buttons. This must be the name of a font-awesome icon. See `http://fontawesome.io/icons/` for a list of icons. button_style: str One of 'primary', 'success', 'info', 'warning' or 'danger'. Applies a predefined style to every button. style: ToggleButtonsStyle Style parameters for the buttons. """ _view_name = Unicode('ToggleButtonsView').tag(sync=True) _model_name = Unicode('ToggleButtonsModel').tag(sync=True) tooltips = List(Unicode(), help="Tooltips for each button.").tag(sync=True) icons = List(Unicode(), help="Icons names for each button (FontAwesome names without the fa- prefix).").tag(sync=True) style = InstanceDict(ToggleButtonsStyle).tag(sync=True, **widget_serialization) button_style = CaselessStrEnum( values=['primary', 'success', 'info', 'warning', 'danger', ''], default_value='', allow_none=True, help="""Use a predefined styling for the buttons.""").tag(sync=True)
class FloatRangeSlider(_BoundedFloatRange): """ Slider/trackbar for displaying a floating value range (within the specified range of values). Parameters ---------- value : float tuple range of the slider displayed min : float minimal position of the slider max : float maximal position of the slider step : float step of the trackbar description : str name of the slider orientation : {'vertical', 'horizontal}, optional default is horizontal readout : {True, False}, optional default is True, display the current value of the slider next to it slider_color : str Unicode color code (eg. '#C13535'), optional color of the slider color : str Unicode color code (eg. '#C13535'), optional color of the value displayed (if readout == True) """ _view_name = Unicode('FloatSliderView', sync=True) orientation = CaselessStrEnum(values=['horizontal', 'vertical'], default_value='horizontal', help="Vertical or horizontal.", sync=True) _range = Bool(True, help="Display a range selector", sync=True) readout = Bool(True, help="Display the current value of the slider next to it.", sync=True) slider_color = Color(None, allow_none=True, sync=True)
class FloatSlider(_BoundedFloat): """ Slider/trackbar of floating values with the specified range. Parameters ---------- value : float position of the slider min : float minimal position of the slider max : float maximal position of the slider step : float step of the trackbar description : str name of the slider orientation : {'vertical', 'horizontal}, optional default is horizontal readout : {True, False}, optional default is True, display the current value of the slider next to it slider_color : str Unicode color code (eg. '#C13535'), optional color of the slider color : str Unicode color code (eg. '#C13535'), optional color of the value displayed (if readout == True) """ _view_name = Unicode('FloatSliderView').tag(sync=True) _model_name = Unicode('IntSliderModel').tag(sync=True) orientation = CaselessStrEnum(values=['horizontal', 'vertical'], default_value='horizontal', help="Vertical or horizontal.").tag(sync=True) _range = Bool(False, help="Display a range selector").tag(sync=True) readout = Bool(True, help="Display the current value of the slider next to it.").tag(sync=True) slider_color = Color(None, allow_none=True).tag(sync=True) continuous_update = Bool(True, help="Update the value of the widget as the user is sliding the slider.").tag(sync=True)
class IntRangeSlider(_BoundedIntRange): """Slider widget that represents a pair of ints bounded by minimum and maximum value. Parameters ---------- lower: int The lower bound of the range upper: int The upper bound of the range min: int The lowest allowed value for `lower` max: int The highest allowed value for `upper` """ _view_name = Unicode('IntSliderView').tag(sync=True) _model_name = Unicode('IntSliderModel').tag(sync=True) orientation = CaselessStrEnum( values=['horizontal', 'vertical'], default_value='horizontal', help="Vertical or horizontal.").tag(sync=True) _range = Bool(True, help="Display a range selector").tag(sync=True) readout = Bool( True, help="Display the current value of the slider next to it.").tag( sync=True) slider_color = Color(None, allow_none=True).tag(sync=True) continuous_update = Bool( True, help="Update the value of the widget as the user is sliding the slider." ).tag(sync=True)
class PredictionConfig(Configurable): # not configurable elements = List( trait=Unicode, help='All elements contained in the dataset listed internally') # configurable data_file = Path(help='Path to a data file used for HDNNP prediction. ' 'Only .xyz file format is supported.').tag(config=True) tags = List(trait=Unicode, default_value=['*'], help='List of dataset tags. ' 'Use dataset for HDNNP training in this order. ' 'Pattern matching is available.').tag(config=True) load_dir = Path( default_value='output', help='Path to directory to load training output files').tag( config=True) order = Integer(help='Order of differentiation used for calculation ' 'of descriptor & property datasets and HDNNP prediction. ' 'ex.) 0: energy, 1: force, for interatomic potential').tag( config=True) dump_format = CaselessStrEnum( ['.npz'], default_value='.npz', help='File format to output HDNNP predition result').tag(config=True)
class CameraR1CalibratorFactory(Factory): name = "CameraR1CalibratorFactory" description = "Obtain CameraR1Calibrator based on file origin" subclasses = Factory.child_subclasses(CameraR1Calibrator) subclass_names = [c.origin for c in subclasses] origin = CaselessStrEnum(subclass_names, 'hessio', help='Origin of events to be ' 'calibration.').tag(config=True) # Product classes traits pedestal_path = Unicode('', allow_none=True, help='Path to a pedestal file').tag(config=True) tf_path = Unicode('', allow_none=True, help='Path to a Transfer Function file').tag(config=True) adc2pe_path = Unicode('', allow_none=True, help='Path to an adc2pe file').tag(config=True) def get_factory_name(self): return self.name def get_product_name(self): return self.origin
class LatexConfig(Configurable): """ A Configurable that declares the configuration options for the LatexHandler. """ latex_command = Unicode( 'xelatex', config=True, help='The LaTeX command to use when compiling ".tex" files.') bib_command = Unicode( 'bibtex', config=True, help='The BibTeX command to use when compiling ".tex" files.') synctex_command = Unicode( 'synctex', config=True, help= 'The synctex command to use when syncronizing between .tex and .pdf files.' ) shell_escape = CaselessStrEnum(['restricted', 'allow', 'disallow'], default_value='restricted', config=True, help='Whether to allow shell escapes '+\ '(and by extension, arbitrary code execution). '+\ 'Can be "restricted", for restricted shell escapes, '+\ '"allow", to allow all shell escapes, or "disallow", '+\ 'to disallow all shell escapes') run_times = Integer(default_value=1, config=True, help='How many times to compile the ".tex" files.') cleanup = Bool(default_value=True, config=True, help='Whether to clean up ".out/.aux" files or not.')
class IntRangeSlider(_BoundedIntRange): """Slider/trackbar that represents a pair of ints bounded by minimum and maximum value. Parameters ---------- value : int tuple The pair (`lower`, `upper`) of integers min : int The lowest allowed value for `lower` max : int The highest allowed value for `upper` """ _view_name = Unicode('IntSliderView').tag(sync=True) _model_name = Unicode('IntSliderModel').tag(sync=True) orientation = CaselessStrEnum( values=['horizontal', 'vertical'], default_value='horizontal', help="Vertical or horizontal.").tag(sync=True) _range = Bool(True, help="Display a range selector").tag(sync=True) readout = Bool( True, help="Display the current value of the slider next to it.").tag( sync=True) continuous_update = Bool( True, help="Update the value of the widget as the user is sliding the slider." ).tag(sync=True) style = InstanceDict(SliderStyle).tag(sync=True, **widget_serialization)
class WaveformCleanerFactory(Factory): """ Factory to obtain a WaveformCleaner. """ name = "WaveformCleanerFactory" description = "Obtain WavefromCleaner based on cleaner traitlet" subclasses = Factory.child_subclasses(WaveformCleaner) subclass_names = [c.__name__ for c in subclasses] cleaner = CaselessStrEnum(subclass_names, 'NullWaveformCleaner', help='Waveform cleaning method to ' 'use.').tag(config=True) # Product classes traits window_width = Int(16, help='Define the width of the pulse ' 'window').tag(config=True) window_shift = Int(8, help='Define the shift of the pulse window from the ' 'peakpos (peakpos - shift).').tag(config=True) def get_factory_name(self): return self.name def get_product_name(self): return self.cleaner
class FloatSlider(_BoundedFloat): """ Slider/trackbar of floating values with the specified range. Parameters ---------- value : float position of the slider min : float minimal position of the slider max : float maximal position of the slider step : float step of the trackbar description : str name of the slider orientation : {'horizontal', 'vertical'} default is 'horizontal', orientation of the slider readout : {True, False} default is True, display the current value of the slider next to it readout_format : str default is '.2f', specifier for the format function used to represent slider value for human consumption, modeled after Python 3's format specification mini-language (PEP 3101). """ _view_name = Unicode('FloatSliderView').tag(sync=True) _model_name = Unicode('FloatSliderModel').tag(sync=True) step = CFloat(0.1, help="Minimum step to increment the value").tag(sync=True) orientation = CaselessStrEnum(values=['horizontal', 'vertical'], default_value='horizontal', help="Vertical or horizontal.").tag(sync=True) readout = Bool(True, help="Display the current value of the slider next to it.").tag(sync=True) readout_format = Unicode('.2f', help="Format for the readout").tag(sync=True) continuous_update = Bool(True, help="Update the value of the widget as the user is holding the slider.").tag(sync=True) style = InstanceDict(SliderStyle).tag(sync=True, **widget_serialization)
class IntRangeSlider(_BoundedIntRange): """Slider/trackbar that represents a pair of ints bounded by minimum and maximum value. Parameters ---------- value : int tuple The pair (`lower`, `upper`) of integers min : int The lowest allowed value for `lower` max : int The highest allowed value for `upper` """ _view_name = Unicode('IntRangeSliderView').tag(sync=True) _model_name = Unicode('IntRangeSliderModel').tag(sync=True) step = CInt(1, help="Minimum step that the value can take").tag(sync=True) orientation = CaselessStrEnum( values=['horizontal', 'vertical'], default_value='horizontal', help="Vertical or horizontal.").tag(sync=True) readout = Bool( True, help="Display the current value of the slider next to it.").tag( sync=True) readout_format = NumberFormat('d', help="Format for the readout").tag(sync=True) continuous_update = Bool( True, help="Update the value of the widget as the user is sliding the slider." ).tag(sync=True) style = InstanceDict(SliderStyle, help="Slider style customizations.").tag( sync=True, **widget_serialization) disabled = Bool(False, help="Enable or disable user changes").tag(sync=True)
class ToggleButton(_Bool): """Displays a boolean `value` in the form of a toggle button. Parameters ---------- value : {True,False} value of the toggle button: True-pressed, False-unpressed description : str description displayed on the button icon: str font-awesome icon name style: instance of DescriptionStyle styling customizations button_style: enum button predefined styling """ _view_name = Unicode('ToggleButtonView').tag(sync=True) _model_name = Unicode('ToggleButtonModel').tag(sync=True) icon = Unicode('', help="Font-awesome icon.").tag(sync=True) button_style = CaselessStrEnum( values=['primary', 'success', 'info', 'warning', 'danger', ''], default_value='', help="""Use a predefined styling for the button.""").tag(sync=True) style = InstanceDict(ToggleButtonStyle, help="Styling customizations").tag( sync=True, **widget_serialization)
class Toolbar(DOMWidget, NavigationToolbar2WebAgg): _model_module = Unicode('jupyter-matplotlib').tag(sync=True) _model_module_version = Unicode(js_semver).tag(sync=True) _model_name = Unicode('ToolbarModel').tag(sync=True) _view_module = Unicode('jupyter-matplotlib').tag(sync=True) _view_module_version = Unicode(js_semver).tag(sync=True) _view_name = Unicode('ToolbarView').tag(sync=True) toolitems = List().tag(sync=True) orientation = Enum(['horizontal', 'vertical'], default_value='vertical').tag(sync=True) button_style = CaselessStrEnum( values=['primary', 'success', 'info', 'warning', 'danger', ''], default_value='', help="""Use a predefined styling for the button.""").tag(sync=True) collapsed = Bool(True).tag(sync=True) _current_action = Enum(values=['pan', 'zoom', ''], default_value='').tag(sync=True) def __init__(self, canvas, *args, **kwargs): DOMWidget.__init__(self, *args, **kwargs) NavigationToolbar2WebAgg.__init__(self, canvas, *args, **kwargs) self.on_msg(self.canvas._handle_message) def export(self): buf = io.BytesIO() self.canvas.figure.savefig(buf, format='png', dpi='figure') # Figure width in pixels pwidth = (self.canvas.figure.get_figwidth() * self.canvas.figure.get_dpi()) # Scale size to match widget on HiPD monitors width = pwidth / self.canvas._dpi_ratio data = "<img src='data:image/png;base64,{0}' width={1}/>" data = data.format(b64encode(buf.getvalue()).decode('utf-8'), width) display(HTML(data)) @default('toolitems') def _default_toolitems(self): icons = { 'home': 'home', 'back': 'arrow-left', 'forward': 'arrow-right', 'zoom_to_rect': 'square-o', 'move': 'arrows', 'download': 'floppy-o', 'export': 'file-picture-o' } download_item = ('Download', 'Download plot', 'download', 'save_figure') toolitems = (NavigationToolbar2.toolitems + (download_item, )) return [(text, tooltip, icons[icon_name], method_name) for text, tooltip, icon_name, method_name in toolitems if icon_name in icons]
class ToggleButton(_Bool): """Displays a boolean `value` in the form of a toggle button. Parameters ---------- value : {True,False} value of the toggle button: True-pressed, False-unpressed description : str description displayed next to the button tooltip: str tooltip caption of the toggle button icon: str font-awesome icon name """ _view_name = Unicode('ToggleButtonView', sync=True) tooltip = Unicode(help="Tooltip caption of the toggle button.", sync=True) icon = Unicode('', help="Font-awesome icon.", sync=True) button_style = CaselessStrEnum( values=['primary', 'success', 'info', 'warning', 'danger', ''], default_value='', allow_none=True, sync=True, help="""Use a predefined styling for the button.""")
class Box(DOMWidget, CoreWidget): """ Displays multiple widgets in a group. The widgets are laid out horizontally. Parameters ---------- {box_params} Examples -------- >>> import ipywidgets as widgets >>> title_widget = widgets.HTML('<em>Box Example</em>') >>> slider = widgets.IntSlider() >>> widgets.Box([title_widget, slider]) """ _model_name = Unicode('BoxModel').tag(sync=True) _view_name = Unicode('BoxView').tag(sync=True) # Child widgets in the container. # Using a tuple here to force reassignment to update the list. # When a proper notifying-list trait exists, use that instead. children = TypedTuple(trait=Instance(Widget), help="List of widget children").tag( sync=True, **widget_serialization) box_style = CaselessStrEnum( values=['success', 'info', 'warning', 'danger', ''], default_value='', help="""Use a predefined styling for the box.""").tag(sync=True) def __init__(self, children=(), **kwargs): kwargs['children'] = children super().__init__(**kwargs)
class BoxNGL(Box): _gui_style = CaselessStrEnum(['row', 'column'], default_value='row').tag(sync=True) _is_beautified = Bool(False) def __init__(self, *args, **kwargs): self.layout = make_form_item_layout() super(BoxNGL, self).__init__(*args, **kwargs) @observe('_gui_style') def _update_gui_style(self, change): """row or column style """ what = change['new'] self.layout.flex_flow = what.lower() def _ipython_display_(self, *args, **kwargs): super(BoxNGL, self)._ipython_display_(*args, **kwargs) self._beautify() def _update_size(self): for widget in self.children: if isinstance(widget, NGLWidget): widget._remote_call('setSize', target='Widget', args=['60%', '60%']) def _beautify(self): if not self._is_beautified: js_utils._set_notebook_width('60%', left_padding=None) self._update_size() self._is_beautified = True
class SelectionSlider(_SelectionNonempty): """ Slider to select a single item from a list or dictionary. Parameters ---------- {selection_params} {slider_params} """ _view_name = Unicode("SelectionSliderView").tag(sync=True) _model_name = Unicode("SelectionSliderModel").tag(sync=True) orientation = CaselessStrEnum( values=["horizontal", "vertical"], default_value="horizontal", help="Vertical or horizontal.", ).tag(sync=True) readout = Bool( True, help="Display the current selected label next to the slider").tag( sync=True) continuous_update = Bool( True, help="Update the value of the widget as the user is holding the slider." ).tag(sync=True)
class FloatRangeSlider(_FloatRangeSlider.__base__): """ This is a fixed slider widget implementation, allowing values lower than 10^-6. This class should be removed at some point, when the slider implementation is fixed in ipywidgets. """ _view_name = Unicode('FixedFloatRangeSliderView').tag(sync=True) _model_name = Unicode('FixedFloatRangeSliderModel').tag(sync=True) _view_module = Unicode('odysis').tag(sync=True) _model_module = Unicode('odysis').tag(sync=True) _view_module_version = Unicode(odysis_version).tag(sync=True) _model_module_version = Unicode(odysis_version).tag(sync=True) step = CFloat(0.01, help="Minimum step to increment the value").tag(sync=True) orientation = CaselessStrEnum( values=['horizontal', 'vertical'], default_value='horizontal', help="Vertical or horizontal.").tag(sync=True) readout = Bool( True, help="Display the current value of the slider next to it.").tag( sync=True) readout_format = NumberFormat('.2e', help="Format for the readout").tag(sync=True) continuous_update = Bool( True, help="Update the value of the widget as the user is sliding the slider." ).tag(sync=True) disabled = Bool(False, help="Enable or disable user changes").tag(sync=True) style = InstanceDict(SliderStyle).tag(sync=True, **widget_serialization)