Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • ManagerBase
    • default

Index

Constructors

constructor

  • Parameters

    • el: any

    Returns default

Properties

Readonly comm_target_name

comm_target_name: "jupyter.widget" = "jupyter.widget"

The comm target name to register

Private el

el: any

Methods

_create_comm

  • _create_comm(): Promise<never>
  • Returns Promise<never>

_get_comm_info

  • _get_comm_info(): Promise<{}>
  • Returns Promise<{}>

Protected _loadFromKernel

  • _loadFromKernel(): Promise<void>
  • Fetch all widgets states from the kernel using the control comm channel If this fails (control comm handler not implemented kernel side), it will fall back to _loadFromKernelModels.

    This is a utility function that can be used in subclasses.

    Returns Promise<void>

Protected _loadFromKernelModels

  • _loadFromKernelModels(): Promise<void>
  • Old implementation of fetching widget models one by one using the request_state message on each comm.

    This is a utility function that can be used in subclasses.

    Returns Promise<void>

_make_model

  • _make_model(options: RequiredSome<IModelOptions, "model_id">, serialized_state?: any): Promise<WidgetModel>
  • Parameters

    • options: RequiredSome<IModelOptions, "model_id">
    • Optional serialized_state: any

    Returns Promise<WidgetModel>

callbacks

  • callbacks(view?: WidgetView): ICallbacks
  • callback handlers specific to a view

    Parameters

    • Optional view: WidgetView

    Returns ICallbacks

clear_state

  • clear_state(): Promise<void>
  • Close all widgets and empty the widget state.

    Returns Promise<void>

    Promise that resolves when the widget state is cleared.

create_view

  • create_view<VT>(model: DOMWidgetModel, options?: any): Promise<VT>
  • create_view<VT>(model: WidgetModel, options?: any): Promise<VT>
  • Creates a promise for a view of a given model

    Notes

    The implementation must trigger the Lumino 'after-attach' and 'after-show' events when appropriate, which in turn will trigger the view's 'displayed' events.

    Make sure the view creation is not out of order with any state updates.

    Type parameters

    • VT: DOMWidgetView<VT> = DOMWidgetView

    Parameters

    • model: DOMWidgetModel
    • Optional options: any

    Returns Promise<VT>

  • Type parameters

    • VT: WidgetView<VT> = WidgetView

    Parameters

    • model: WidgetModel
    • Optional options: any

    Returns Promise<VT>

disconnect

  • disconnect(): void
  • Disconnect the widget manager from the kernel, setting each model's comm as dead.

    Returns void

display_view

  • display_view(view: any): Promise<any>
  • Parameters

    • view: any

    Returns Promise<any>

Protected filterExistingModelState

  • filterExistingModelState(serialized_state: any): any
  • Filter serialized widget state to remove any ID's already present in manager.

    Parameters

    • serialized_state: any

    Returns any

    A copy of the state, with its 'state' attribute filtered

get_model

  • get_model(model_id: string): Promise<WidgetModel>
  • Get a promise for a model by model id.

    Notes

    If the model is not found, the returned Promise object is rejected.

    If you would like to synchronously test if a model exists, use .has_model().

    Parameters

    • model_id: string

    Returns Promise<WidgetModel>

get_state

  • get_state(options?: IStateOptions): Promise<IManagerState>
  • Asynchronously get the state of the widget manager.

    This includes all of the widget models, and follows the format given in the @jupyter-widgets/schema package.

    Parameters

    • Optional options: IStateOptions

      The options for what state to return.

    Returns Promise<IManagerState>

    Promise for a state dictionary

handle_comm_open

  • handle_comm_open(comm: IClassicComm, msg: ICommOpenMsg<"iopub" | "shell">): Promise<WidgetModel>
  • Handle when a comm is opened.

    Parameters

    • comm: IClassicComm
    • msg: ICommOpenMsg<"iopub" | "shell">

    Returns Promise<WidgetModel>

has_model

  • has_model(model_id: string): boolean
  • Returns true if the given model is registered, otherwise false.

    Notes

    This is a synchronous way to check if a model is registered.

    Parameters

    • model_id: string

    Returns boolean

inline_sanitize

  • inline_sanitize(source: string): string
  • Parameters

    • source: string

    Returns string

loadClass

  • loadClass(className: string, moduleName: string, moduleVersion: string): Promise<any>
  • Parameters

    • className: string
    • moduleName: string
    • moduleVersion: string

    Returns Promise<any>

Protected loadModelClass

  • loadModelClass(className: string, moduleName: string, moduleVersion: string): Promise<typeof WidgetModel>
  • Parameters

    • className: string
    • moduleName: string
    • moduleVersion: string

    Returns Promise<typeof WidgetModel>

Protected loadViewClass

  • loadViewClass(className: string, moduleName: string, moduleVersion: string): Promise<typeof WidgetView>
  • Parameters

    • className: string
    • moduleName: string
    • moduleVersion: string

    Returns Promise<typeof WidgetView>

new_model

  • new_model(options: IModelOptions, serialized_state?: any): Promise<WidgetModel>
  • Create and return a promise for a new widget model

    example

    widget_manager.new_model({ model_name: 'IntSlider', model_module: '@jupyter-widgets/controls', model_module_version: '1.0.0', model_id: 'u-u-i-d' }).then((model) => { console.log('Create success!', model); }, (err) => {console.error(err)});

    Parameters

    • options: IModelOptions

      the options for creating the model.

    • Optional serialized_state: any

      attribute values for the model.

    Returns Promise<WidgetModel>

new_widget

  • new_widget(options: IWidgetOptions, serialized_state?: JSONObject): Promise<WidgetModel>
  • Create a comm and new widget model.

    Parameters

    • options: IWidgetOptions

      same options as new_model but comm is not required and additional options are available.

    • Optional serialized_state: JSONObject

      serialized model attributes.

    Returns Promise<WidgetModel>

register_model

  • register_model(model_id: string, modelPromise: Promise<WidgetModel>): void
  • Parameters

    • model_id: string
    • modelPromise: Promise<WidgetModel>

    Returns void

resolveUrl

  • resolveUrl(url: string): Promise<string>
  • Resolve a URL relative to the current notebook location.

    The default implementation just returns the original url.

    Parameters

    • url: string

    Returns Promise<string>

setViewOptions

  • setViewOptions(options?: any): any
  • Modifies view options. Generally overloaded in custom widget manager implementations.

    Parameters

    • Optional options: any

    Returns any

set_state

  • set_state(state: IManagerState): Promise<WidgetModel[]>
  • Set the widget manager state.

    Parameters

    • state: IManagerState

      a Javascript object conforming to the application/vnd.jupyter.widget-state+json spec.

      Reconstructs all of the widget models in the state, merges that with the current manager state, and then attempts to redisplay the widgets in the state.

    Returns Promise<WidgetModel[]>

Generated using TypeDoc