Bokeh custom model registration

What are you trying to do?
I’m trying to create a basic custom model that extends the Select model.

What have you tried that did NOT work as expected? If you have also posted this question elsewhere (e.g. StackOverflow), please include a link to that post.
I made a class and typescript code where I create the custom model and have it import extend Select. Every time I get the “Error: could not resolve type ‘mySelect’, which could be due to a widget or a custom model not being registered before first usage”

If this is a question about Bokeh code, please include a complete Minimal, Reproducible Example so that reviewers can test and see what you see.
Here is all of my code.

from bokeh.layouts import column
from bokeh.models import Select
from bokeh.plotting import curdoc
from bokeh.util.compiler import TypeScript

CODE = """
import {Select} from "models/widgets"

export class MySelect extends Select {


class mySelect(Select):

    __implementation__ = TypeScript(CODE)

my_select = mySelect(name="my_select", options=['A', 'B', 'C'], value="A")

doc = curdoc()

I tried to make it as simple as possible for a MRE, but I worry that I’ve missed something important because of that. I saw a similar question here that stated I need to add the JS and CSS but I am not entirely sure where to add them. Any help would be much appreciated. This is all with bokeh 3.3.0.

Update: if I use the js cdn in the custom model with __javascript__ = “<cdn link>” I get this error in the console: Uncaught TypeError: bokeh.register_plugin is not a function

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.