moldesign.uibase package

Submodules

moldesign.uibase.components module

class moldesign.uibase.components.AtomInspector(value=None, **kwargs)[source]

Bases: ipywidgets.widgets.widget_string.HTML, moldesign.uibase.selector.Selector

handle_selection_event(selection)[source]
class moldesign.uibase.components.ReadOnlyRepr(*args, **kwargs)[source]

Bases: ipywidgets.widgets.widget_box.Box

When a value is assigned, displays its __repr__ instead

value
class moldesign.uibase.components.ReadoutFloatSlider(format=None, *args, **kwargs)[source]

Bases: ipywidgets.widgets.widget_box.Box

description

A trait for unicode strings.

parse_value(*args)[source]
update_readout
value

A float trait.

class moldesign.uibase.components.SelBase(mol)[source]

Bases: moldesign.uibase.components.ViewerToolBase

static atomkey(atom)[source]
clear_selections(*args)[source]
handle_remove_button_click(*args)[source]
remove_atomlist_highlight(*args)[source]
select_all_atoms(*args)[source]
selected_atoms
toggle_atom(atom)[source]

Toggles atom’s state in and out of the selection group

class moldesign.uibase.components.StyledTab(*args, **kwargs)[source]

Bases: ipywidgets.widgets.widget_selectioncontainer.Tab

Objects can inherit from this to maintain consistent styling. TODO: Probably better to do this with CSS?

class moldesign.uibase.components.UnitText(value=None, units=None, **kwargs)[source]

Bases: ipywidgets.widgets.widget_box.Box

Widget for a user to input a quantity with physical units.

Parameters:
  • value (u.Scalar) – initial value for the widget
  • units (u.MdtUnit) – if provided, require that input has the same dimensionality as these units

Note

A very rough approximation of the FloatText, IntText, etc. widgets - this does NOT have a counterpart in JavaScript. But it will behave similarly when setting units and values from python.

INVALID = u'\u274c'
VALID = u'\u2705'
value
class moldesign.uibase.components.ViewerToolBase(mol)[source]

Bases: ipywidgets.widgets.widget_box.Box

The base for most viewer-based widgets - it consists of a viewer in the top-left, UI controls on the right, and some additional widgets underneath the viewer

VIEWERTYPE

alias of GeometryViewer

moldesign.uibase.logwidget module

class moldesign.uibase.logwidget.Logger(title='log', **kwargs)[source]

Bases: object

debug(string)
error(string)
handled(string)
info(string)
status(string)
warning(string)
class moldesign.uibase.logwidget.WidgetValueHandler(widget=None)[source]

Bases: logging.Handler

Appends logging messages to a widget’s value field. Watch this for performance - we’re repeatedly +=’ing a string, which is not good

emit(record)[source]

Emit a record. If a formatter is specified, it is used to format the record. The record is then written to the stream with a trailing newline. If exception information is present, it is formatted using traceback.print_exception and appended to the stream. If the stream has an ‘encoding’ attribute, it is used to determine how to do the output to the stream.

moldesign.uibase.logwidget.display_log(obj, title=None, show=False)[source]

Registers a new view. This is mostly so that we can display all views from a cell in a LoggingTabs object. :param obj: The object to display. If it has a “get_display_object” method, its return value is displayed :param title: A name for the object (otherwise, str(obj) is used) :return:

moldesign.uibase.logwidget.enable_logging_widgets(enable=True)[source]
Parameters:enable – if False, disable it
Returns:

moldesign.uibase.plotting module

moldesign.uibase.plotting.function_slice(f, v, dims, ranges)[source]

Return an arbitrary dimensional slice of function values :param f: function to be evaluated, call signature f(v) :param v: vector that sets the static coordinates :param dims: ndims-length list of dimensions to vary :param ranges: ndims-list of values along those dimensions :return: gridpoints, function values

moldesign.uibase.plotting.grid_map(f, v, dims, grids)[source]

Map function values along a grid :param f: function to be evaluated, call signature f(v) :param v: vector that sets the static coordinates :param dims: ndims-length list of dimensions to vary :param grids: ndims-length list of grid values for each dimension :return: function value grid

moldesign.uibase.selector module

class moldesign.uibase.selector.SelectionGroup(*args, **kwargs)[source]

Bases: ipywidgets.widgets.widget_box.Box

Broadcasts selections among a group of widgets. It doesn’t do much beside rebroadcast events: A SelectionGroup object will call the “handle_selection_event” methods of all of its children whenever its “update_selections” method is called.

color_by(*args, **kwargs)

set_color(*args, **kwargs)

get_child_listeners(element)[source]
register_selection_listeners()[source]
set_color(*args, **kwargs)
set_colors(*args, **kwargs)

set_color(*args, **kwargs)

unset_color(*args, **kwargs)
update_selections(event_source, selection)[source]
class moldesign.uibase.selector.Selector(*args, **kwargs)[source]

Bases: object

This is the abstract base class for something that can make a selection.

fire_selection_event(new_selection)[source]
handle_selection_event(selection)[source]
class moldesign.uibase.selector.ValueSelector(value_selects=None, **kwargs)[source]

Bases: moldesign.uibase.selector.Selector

This is an abstract mixin for a widget class

handle_selection_event(selection)[source]
value_update(*args)[source]
moldesign.uibase.selector.create_value_selector(widget, value_selects, **kwargs)[source]

Creates a UI element (slider, checkbox, etc.) to add to your selection group. :param widget: widget class (e.g. ipywidgets.FloatSlider) :param value_selects: What the value of the widget selects (e.g. time) :param kwargs: keyword arguments for the widget (e.g. description = “time”) :return: the constructed widget