Python bokeh.models.widgets.TextInput() Examples

The following are 1 code examples of bokeh.models.widgets.TextInput(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module bokeh.models.widgets , or try the search function .
Example #1
Source File: __init__.py    From parambokeh with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def change_event(self):
        if not self._queue:
            self._active = False
            return
        w, p_obj, p_name, attr, old, new_values = self._queue[-1]
        self._queue = []

        error = False
        # Apply literal evaluation to values
        if (isinstance(w, TextInput) and isinstance(p_obj, literal_params)):
            try:
                new_values = ast.literal_eval(new_values)
            except:
                error = 'eval'

        if p_name in self._widget_options:
            mapping = self._widget_options[p_name]
            if isinstance(new_values, list):
                new_values = [mapping[el] for el in new_values]
            else:
                new_values = mapping.get(new_values, new_values)

        if isinstance(p_obj, param.Range):
            new_values = tuple(new_values)

        if isinstance(w, CheckboxGroup):
            new_values = True if (len(new_values)>0 and new_values[0]==0) else False

        # If no error during evaluation try to set parameter
        if not error:
            try:
                setattr(self.parameterized, p_name, new_values)
            except ValueError:
                error = 'validation'

        # Style widget to denote error state
        # apply_error_style(w, error)

        if not error and not self.p.button:
            self.execute({p_name: new_values})
        else:
            self._changed[p_name] = new_values

        # document.hold() must have been done already? because this seems to work
        if self.p.mode == 'notebook' and self.p.push and self.document._held_events:
            self._send_notebook_diff()
        self._active = False