examples/web1/index.js
function createWidget(widgetType, value, description) {

        // Create the widget model.
        return manager.new_model({
            model_module: '@jupyter-widgets/controls',
            model_name: widgetType + 'Model',
            model_id: 'widget-1'
        // Create a view for the model.
        }).then(function(model) {
            console.log(widgetType + ' model created');

            model.set({
                description: description || '',
                value: value,
            });

            return  manager.create_view(model);
        }, console.error.bind(console))
        .then(function(view) {
            console.log(widgetType + ' view created');
            manager.display_view(null, view);
            return view;
        }, console.error.bind(console));
    }
function createWidget(widgetType, value, description) {

        // Create the widget model.
        return manager.new_model({
            model_module: '@jupyter-widgets/controls',
            model_name: widgetType + 'Model',
            model_id: 'widget-1'
        // Create a view for the model.
        }).then(function(model) {
            console.log(widgetType + ' model created');

            model.set({
                description: description || '',
                value: value,
            });

            return  manager.create_view(model);
        }, console.error.bind(console))
        .then(function(view) {
            console.log(widgetType + ' view created');
            manager.display_view(null, view);
            return view;
        }, console.error.bind(console));
    }
function createWidget ( widgetType , value , description ) { // Create the widget model. return manager . new_model ( { model_module : '@jupyter-widgets/controls' , model_name : widgetType + 'Model' , model_id : 'widget-1' // Create a view for the model. } ) . then ( function ( model ) { console . log ( widgetType + ' model created' ) ; model . set ( { description : description || '' , value : value , } ) ; return manager . create_view ( model ) ; } , console . error . bind ( console ) ) . then ( function ( view ) { console . log ( widgetType + ' view created' ) ; manager . display_view ( null , view ) ; return view ; } , console . error . bind ( console ) ) ; }
Helper function for creating and displaying widgets.
@return {Promise<WidgetView>}
Helper function for creating and displaying widgets .